Help with a returned function problem

I am having problems making the function to return a value, it ones dis but when the client number is more than 6000 is not going back to the no discount rate, the range for discount is for employees 4000 - 59999, it does fine when is less than 4000, I changed the code and now is not even calculating, any help?

double calcfee(double attorneyhours);
double calcdiscount(double chargedamount);
double calcamt(double chargedamount, double discount);
double calcavg(int counter, double totaldiscounted);

int main()
// Declare variables below here

int clientnumber, casenumber;
double attorneyhours, chargedamount, totalchargedamount;
double discount;
double totaldiscounted=0;
double totalhours=0;
double totalhours2=0;
double avgtotaldiscounted=0;
char ans = 'Y';
int counter=0;

// Initialization Section for real number output. DO NOT MOVE!

cout <<setiosflags(ios::fixed | ios::showpoint);
cout <<setprecision(2);

// Begin your "main processing" below here


cout<<endl<<"\t Welcome to my Legal Office!"<<endl;
cout<<endl<<"Please enter the client number (number can not be 0): ";
cin >> clientnumber;
cout<<"Please enter the case number: ";
cin >> casenumber;
cout<<"Enter the hours worked by the attorney: ";
cin>> attorneyhours;

chargedamount=calcfee(attorneyhours);//calculate the proper charged fees base on hours worked

if(clientnumber> 3999 && clientnumber<5999)
discount=calcdiscount(chargedamount);//calculate the clients that need discount base on their client number
totalchargedamount=calcamt(chargedamount, discount);//calculate the value after the discount

if (attorneyhours>0 && attorneyhours<=20)


cout<<"Client number: "<<clientnumber<<endl;
cout<<"Case number: "<<casenumber<<endl;
cout<<"Amount charged before any fee: "<<chargedamount<<endl;
cout<<"Discount (if qualified) provided: "<<discount<<endl;
cout<<"Total charge amount is going to be: "<<totalchargedamount<<endl<<endl;
cout<<"Enter Y/y if you want to calculate another client: ";
cin >> ans;
cout <<endl;


cout<<"The total amount of hours billed at $150 are: "<<totalhours<<endl;
cout<<"The total amount of hours billed at $100 are: "<<totalhours2<<endl;
cout<<"Total fees billed are: "<<totaldiscounted<<endl;
avgtotaldiscounted=calcavg(counter,totaldiscounted);//calculate the average of the total discount amount
cout<<"Average total fees are: "<<avgtotaldiscounted<<endl<<endl;
cout<<"Thank you for using our services!"<<endl;
cout<<"Stay away from trouble!"<<endl<<endl;
return 0;

double calcfee(double attorneyhours)
double chargedamount;
if ((attorneyhours>0)&&(attorneyhours<=20))
return chargedamount;
double calcdiscount(double chargedamount)
double discount;
//if (clientnumber>3999&&clientnumber<6000)
return discount;

double calcamt(double chargedamount, double discount)
double totalchargedamount;
return totalchargedamount;

double calcavg(int counter, double totaldiscounted)
return totaldiscounted;

Use code tags, no one will read the code like that.
OK, So when the value is LESS THAN OR EQUAL to 4000- there will be NO DISCOUNT, and at this point all is well.

So far we have a problem with the discount when there is to be a discount calculated.

in CalcFee() you preform the calculation, so within this subrt'n I suggest that you STEP through each line of code , and too, print-out each var and its value within this subrt'n.

I would venture to guess that DOUBLE is being created and init'ized to 0 (zero) and that 0 (zero) is later being multiplied by the fee - which usually doesn't make for a great discount amount.

ps, when you get it working, then try re-writing it so that it is easier to read, and is more compact and concise - Right now it's hell to read, and therefore hell to try to de-bug.
I am new on this, so what you mean with code tags?
Also the only problem I was having is when I got to the client number between 4000 and 6000 and try to calculate de fee for 20 hours and more, I beleive my program was right and changed it. What is wron is the Input output table the teacher gave me.
I am new on this, so what you mean with code tags?

You need to surround your code with [code] and [/code]. You also find them to the right.
Topic archived. No new replies allowed.