Last active
August 29, 2015 13:56
-
-
Save laurenkruczyk/9078321 to your computer and use it in GitHub Desktop.
Cash Register Challenge I
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
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