Skip to content

Instantly share code, notes, and snippets.

@townie
Created February 18, 2014 20:00
Show Gist options
  • Save townie/9078797 to your computer and use it in GitHub Desktop.
Save townie/9078797 to your computer and use it in GitHub Desktop.
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
@townie
Copy link
Author

townie commented Feb 18, 2014

WOOT WOOT

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