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?
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;
cout<<endl;
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
counter=counter+1;
totaldiscounted=totaldiscounted+discount;
}
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;
}while((ans=='Y'||ans=='y'));
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;
}
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.