Collaboration Exercises
Exercise 1
Prompt the user for the following information:
- Name
- How many peaches would they like to buy at $0.69 each?
- How many apples would they like to buy at $0.49 each?
- How many pears would they like to buy at $0.99 each?
Then display text that shows the following:
A friendly greeting that includes the visitor's name.
A nicely formatted list of the items the visitor has selected to buy,
including the total price for each item.
The total price of all the items ordered.
Exercise 2
Expand your code above. Ask the user how much they will pay. Then, compute
the amount of change they will receive.
You must compute the change as follows.
- You can only give change in coins: quarters, dimes, nickels and
pennies.
- You must give the minimum number of coins (e.g. you can't
give 26 pennies if you can give 1 quarter and 1 penny).
For example, if the bill is $8.36 and the amount tendered is $10.00,
then the change is $1.64:
6 quarters
1 dime
0 nickels
4 pennies
You can assume that the amount tendered is always
greater than or equal to the total bill.