### Can anyone help with this program?

closed account (4wRjE3v7)
Hi I started to learn c++ and I really need help with this program. can anyone help or give me advice?

Scenario: Kids these days! You are the new shift manager at the
* local Tast-E-Freeze ice cream shop. Every day the high schoolers
* working the counter are up in arms about the fact that you expect
* them to make change WITHOUT A CALCULATOR! Needless to say, the
* cash balance is always off at the end of the day. You are fed up
* and decide to write a program to help the kids make change. What
* are they teaching in school these days anyway??!!
*
* INPUT: Ask the teenie-bopper working the desk to enter the amount due
* and the amount paid by the customer
* OUTPUT: The number of dollars, quarters, dimes, nickels and pennies (s)he will
* need to use to give the customer the correct change
* ******************************************************** */

#include <iostream>
using namespace std;

int main()
{
double ice_cream_bill, customer_cash;

cout << "How much was the customer's bill?: \$";
cin >> ice_cream_bill;
}
You can start by writing down the logic of the program. It's like this: you need to ask for the bill and get the input (done), then the same thing for the amount paid. Then it's a simple task of doing the math according to how you want the change to be distributed among the type of money (I'm not familiar with american subdollar money), and then display that amount.
Last edited on
Your next step is to divide the bill into change depending on how much input your expecting.

For example if you get a 100 dollar bill for a ice-cream bar that costs 1.25 you'll need a good 50, 20, and 10 bills. You'll also need change in form of quarters.
So if you were to expect those amounts you would need variables for those amounts:
`double fifty, twenty, ten, quarters;`

To start you must find the total change. In my example it would be 98.75. To express this would be a new variable initialization:

`double total_change = customer_cash - ice_cream_bill;`

or equally so you could split it up as a declaration and assignment:

 ``12`` ``````double total_change; total_change = customer_cash - ice_cream_bill;``````

Next you must proceed to breaking down the bill into change. It would go along the lines of this:
 ``12`` ``````fifty = ice_cream_bill / fifty; // fifty = however many times you can divide the bill by. In this case 1 ice_cream_bill = ice_cream_bill % fifty; // ice_cream_bill = what is left after subtracting the fifty dollar bills you've contributed to the change. ``````

This should get you started. If you need further clarification or help let us know.
Last edited on
Topic archived. No new replies allowed.