Skip to content

Instantly share code, notes, and snippets.

@laurenkruczyk
Last active August 29, 2015 13:56
Show Gist options
  • Save laurenkruczyk/9078321 to your computer and use it in GitHub Desktop.
Save laurenkruczyk/9078321 to your computer and use it in GitHub Desktop.
Cash Register Challenge I
puts "What is the amount due?"
amount_due = gets.chomp.to_f
puts "What is the amount tendered?"
amount_provided = gets.chomp.to_f
change = amount_provided-amount_due
if change > 0
puts "The total change due is $#{sprintf("%.2f", change)} #{Time.now.strftime("%A, %D")}"
elsif change < 0
puts "WARNING: Customer still owes $ #{sprintf('%.2f',change.abs)}"
exit
elsif change == 0
puts "You don't need to give change! (#{Time.now})"
end
puts "==Thank You!=="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment