using namespace std;
int amount_total(int amount_paid, int& amountleft), quarters(int&
amountleft), dimes(int& amountleft), pennies(int& amountleft);
int amount_total(int amount_paid, int& amountleft)
{
const int TOTALVALUE = 99;
cout << "You have bought a candy bar that's 99 cents. \n"
<< "Please insert the amount paid. " << endl;
cin >> amount_paid;
amountleft = TOTALVALUE - amount_paid;
cout << "You have to pay : " << amountleft << " cents. \n" << endl;
return(0);
}
int quarters(int& amountleft)
{
const int QUARTERS = 25;
int total, count_Quarters;
count_Quarters = 0;
while (amountleft > 0 || amountleft >= QUARTERS)
{
total = amountleft - QUARTERS;
count_Quarters++;
}
return(count_Quarters);
}
int dimes(int& amountleft)
{
const int DIMES = 10, QUARTERS = 25;
int total, count_Dimes;
count_Dimes = 0;
while (amountleft > 0 || amountleft <= QUARTERS)
{
total = amountleft - DIMES;
count_Dimes++;
}
return(count_Dimes);
}
int pennies(int& amountleft)
{
const int PENNIES = 1, DIMES = 10;
int total, count_Pennies;
count_Pennies = 0;
while (amountleft >= 0 || amountleft <= DIMES)
{
total = amountleft - PENNIES;
count_Pennies++;
}
return(count_Pennies);
}
int main()
{
int amount_paid, amountleft, Count_Quarters,
Count_Dimes, Count_Pennies, total_amount;
total_amount = amount_total(amount_paid, amountleft);
Count_Quarters = quarters(amountleft);
Count_Dimes = dimes(amountleft);
Count_Pennies = pennies(amountleft);
cout << "You'll get : " << Count_Quarters << " quarters, " <<
Count_Dimes << " dimes, and " << Count_Pennies << " pennies. \n"
<< endl;
return 0;
}
//sample run:
You have bought a candy bar that's 99 cents. Please insert the amount paid. 36 You have to pay : 63 cents.
What my original plan was for the program to run and the main would just run through the functions and the functions would return the variable, however it's not doing that and it's only running the first function