|
-
March 5th, 2004, 01:11 AM
#1
I've run into a bit of a problem
I am taking a c++ class and I have a program due, the assignment is to write a program that uses functions with reference parameters that will have the user input the amount of a purchase and the amount tendered, then it will calculate how many 10 dollar bills, 5 dollar bills, 1 dollar bills, quarters, dimes, nickels, pennies are due back, then output it. I've run into a problem because I'm not quite exactly sure how to start it, mainly Im not sure how I would do the math (mainly the math is the part I'm having trouble in). I forgot to add that int main() can only include function calls and variable declarations, all the math and stuff must be done in functions...
my calcChangedue function is
void calcChanDue(double amtTen, double purchtotal, double &tendoll, double &fivedoll,double &onedoll, double &quarter, double &dime, double &nickel, double &penny);
{
double difference=amtTen-purchtotal;
//ten dollar bill
therest=difference%10;
tendoll=ceil(difference/10);
//fivedollar bill
therest=therest%5;
fivedoll=ceil(therest/5);
//onedollarbill
therest=therest%1;
onedoll=ceil(therest/1);
//quarters
therest=therest%.25;
quarter=ceil(therest/.25);
//dimes
therest=therest%.10;
dime=ceil(therest/.10);
//nickels
therest=therest%.05;
nickel=ceil(therest/.05);
//pennies
therest=therest%.01;
penny=ceil(therest/.01);
return;
}
//end function
Last edited by chaos9786; March 5th, 2004 at 01:13 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|