C# don't understand calling methods. object oriented programming -


i've started object oriented programming , don't quite understand how call method. wanted calculate percentage increase , put out resulting overall price. done calling method working out returning value other method. i'm unsure how cross on between methods.

could please explain how i'm meant this? preferably not giving answer can understand what's happening.

p.s. piece of code in class called retailpricing. i've copied , pasted it, doesn't it's formatted (i understand how call class main program)

namespace week7exercise2 {     class retailpricing     {         public void calculateretailprice()         {             double inputcost;             double inputpercent;             string inputitemcost;             string inputmarkup;              console.write("please input cost of item: ");             inputitemcost = console.readline();             inputcost = double.parse(inputitemcost);              console.write("please input markup percentage: ");             inputmarkup = console.readline();             inputpercent = double.parse(inputmarkup);              console.write("your retail price is: " + newprice);         }          public double sum(double markuppercentage, double overallprice, double newprice)         {                         markuppercentage = inputpercent + 100;             overallprice = markuppercentage / 100;             newprice = inputcost * overallprice;             return newprice;         }     }    } 

what understood want call function perform calculations.

before last line:

console.write("your retail price is: " + newprice); 

what need call function calculating price , it'll return price after calculating it. do:

double newprice = sum(inputpercent,inputcost) 

and change sum function to:

public double sum(double markuppercentage, double overallprice)     {                     markuppercentage = inputpercent + 100;         overallprice = markuppercentage / 100;         double newprice = inputcost * overallprice;         return newprice;     } 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -