Create a program that calculates change after a purchase


Create a program that calculates change after a purchase. This will be a sequential algorithm, which is one of the simplest programming patterns. Your solution requires no branching or looping. Simply write a series of statements that will execute in order.

The program should ask for a purchase price and the amount of cash tendered. It should then determine how many of the following denomininations should be returned:
penny
$0.01
nickel
$0.05
dime
$0.10
quarter
$0.25
dollar
$1.00
five
$5.00
ten
$10.00
twenty
$20.00


Sample Run

Price of the item:
21.37
Cash tendered:
50.00
Change: 28.63
Change Left: 2863
twenties: 1
tens: 0
fives: 1
ones: 3
quarters: 2
dimes: 1
nickles: 0
pennies: 3
Notes

This program is easier if you consider the following ideas:
You'll have to figure out how much of each amount is required
You'll need to know what's left after you've accounted for each denomination
Look up the modulus operator
Modulus works better with integers
It may be better to work in pennies rather than dollars

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Create a program that calculates change after a purchase
Reference No:- TGS0965252

Now Priced at $20 (50% Discount)

Recommended (90%)

Rated (4.3/5)