Hello. I am getting into functions in my computer science class and have an assignment that requires one. I sort of understand them, but obviously not TOO well. I have messed around using functions in a side project I did for myself, but it was simple arithmetic problems. However, this problem is confusing me and I just can't understand why it won't work. If someone may be kind to further explain and point me in the right direction, I would appreciate it so much.
Well, no worries- your mistake is not too awful of one. Line 27: cout << totalBill(totalIncome, consultTime, payRate);
But the function is: double totalBill(double payRate, double consultTime, double totalIncome);
Thank you so much Ispil! That did it. Now I have a question, after this problem I encountered where I had the variables backwards, I am assuming when I call a function, the variables have to be in the same order as the ones in the function?
Mobutus, I just have the habit to initialize the variables I use. If I am thinking along the same lines as you, I was thinking I could use
1 2 3 4 5 6 7 8
if (totalIncome <= 25000 && consultTime <= 30){
cout << "There is no charge." << endl;
}
else {
total = payRate * 0.40 * ((consultTime - 30) / 60);
cout << "Your total is = ";
return total;
}//end else
Was that what you were referring to? Also, since I deleted return 0; from the if statement, I get some weird error after the program runs.
How can I get "There is no charge" to return without return 0; ? With return 0;, it would return a 0...