Created
February 18, 2014 17:07
-
-
Save allcentury/9075168 to your computer and use it in GitHub Desktop.
Cash Register 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#User story: As a cashier | |
#I want to calculate the change due | |
#So I know how much to give back to the customer | |
t = Time.now | |
puts "What is the amount due?" | |
amount_due = gets.chomp.to_f | |
puts "What is the amount tendered?" | |
amount_tendered = gets.chomp.to_f | |
if amount_tendered >= amount_due | |
puts "===Thank You!===" | |
puts "The total change due is $#{"%0.2f" % (amount_tendered-amount_due)} \n " | |
puts t.strftime("%m/%d/%Y %I:%M%p") # Format should be 02/12/2013 5:50PM | |
puts "================" | |
else | |
puts " \nWARNING: Customer still owes $#{"%0.2f" % (amount_due-amount_tendered)}! Exiting..." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Coded by: Anthony, Dan & Greg S