Created
February 18, 2014 20:00
-
-
Save townie/9078797 to your computer and use it in GitHub Desktop.
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
def getdue | |
puts "What is the amount due?" | |
due = gets.chomp | |
if !( /^\d*\.?\d{0,2}/.match(due) ) | |
getdue | |
end | |
due.to_f | |
end | |
def gettend | |
puts "What is the amount tendered?" | |
tend = gets.chomp | |
if !(/^\d*\.?\d{0,2}/.match(tend)) | |
gettend | |
end | |
tend.to_f | |
end | |
due = getdue | |
tend = gettend | |
if due <= tend | |
puts "=====Thank You!=====" | |
total = sprintf "%.2f" , tend - due | |
puts "Change due is $#{total} " | |
puts Time.now.strftime('%m/%d/%y %l:%m%p') | |
puts "=" *20 | |
else | |
total = sprintf "%.2f" , due - tend | |
puts "WARNING: Customer still owes $#{total}! Exiting..." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
WOOT WOOT