Skip to content

Instantly share code, notes, and snippets.

@adeng21
Created February 18, 2014 19:19
Show Gist options
  • Save adeng21/9077926 to your computer and use it in GitHub Desktop.
Save adeng21/9077926 to your computer and use it in GitHub Desktop.
Cash Register Challenge 1
puts "What is the amount due?"
total = gets.chomp.to_f
puts "What is the amount tendered?"
paid = gets.chomp.to_f
if paid < total
puts "WARNING: Customer still owes $#{format("%.2f", total-paid)}"
puts Time.now
elsif paid > total
puts "The total change due is $#{format("%.2f", paid-total)}"
puts Time.now
else
puts "Exact amount tendered. No change due"
puts Time.now
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment