Final answer:
A cash register program calculates change by first asking for the cost of three items, totaling the cost, asking for the amount paid, and then calculating and printing the change due.
Step-by-step explanation:
To write a cash register program that calculates change for a restaurant, you would need to perform several steps. Here's how such a program might work:
- First, prompt the user to input the cost of three items purchased by the customer.
- Next, tell the user the total cost of the items purchased by adding up the cost of the three items.
- Then, ask the user to input the amount paid by the customer.
- Finally, calculate and print the amount of change to be given to the customer by subtracting the total cost from the amount paid.
For example, if the three items cost $5.00, $7.50, and $3.25 respectively, the total cost would be $15.75. If the customer pays with a $20 bill, the program should calculate the change as $4.25 and print that information out for the user.