Skip to content

Instantly share code, notes, and snippets.

@allcentury
Created February 18, 2014 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allcentury/9075168 to your computer and use it in GitHub Desktop.
Save allcentury/9075168 to your computer and use it in GitHub Desktop.
Cash Register 1
#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
@allcentury
Copy link
Author

Coded by: Anthony, Dan & Greg S

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment