--Change calculator
function getChange( money )
--Convert from dollars and cents to just cents
money = math.floor( ( money * 100 ) )
--Process
print( "Your change - " )
quarters = math.floor( ( money / 25 ) )
if( quarters > 0 ) then
money = money - ( quarters * 25 )
print( "Quarters: " .. tostring( quarters ) )
end
dimes = math.floor( ( money / 10 ) )
if( dimes > 0 ) then
money = money - ( dimes * 10 )
print( "Dimes: " .. tostring( dimes ) )
end
nickels = math.floor( ( money / 5 ) )
if( nickels > 0 ) then
money = money - ( nickels * 5 )
print( "Nickels: " .. tostring( nickels ) )
end
pennies = ( money / 1 )
if( pennies > 0 ) then
money = money - pennies
print( "Pennies: " .. tostring( pennies ) )
end
end
print( "How much money do you have?" )
userInput = io.read()
getChange( userInput )