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

So far I have:

- Code: Select all
`# ask user price of the item they want to purchase`

varPrice = raw_input("Price of the item: ")

# ask user amount of cash tendered

varCashPaid = raw_input("Cash tendered: ")

# calculate and state change

varChange = float(varCashPaid) - float(varPrice)

float(varChange)

print "Change: ", varChange

# convert change to pennies

varChangeLeft = float(varChange) * 100

print "Change Left: ",varChangeLeft

How do I get further? I am having trouble figuring out how to determine the amount of each denomination of change that should be returned.