Skip to content

Instantly share code, notes, and snippets.

@alacritythief
Created August 12, 2014 16:58
Show Gist options
  • Save alacritythief/47e38dbe815250340554 to your computer and use it in GitHub Desktop.
Save alacritythief/47e38dbe815250340554 to your computer and use it in GitHub Desktop.
puts "What is the amount due?"
amt_due = gets.to_f
puts "What is the amount tendered?"
amt_tnd = gets.to_f
if amt_tnd == amt_due
puts "========== Thank You! ============"
puts Time.now.strftime("%m/%d/%Y %l:%M")
puts "=================================="
else
change = amt_tnd - amt_due
tender = sprintf('%.2f', change.abs)
if change > 0
puts "========== Thank You! ============"
puts "The total change due is $#{tender}"
puts Time.now.strftime("%m/%d/%Y %l:%M")
puts "=================================="
else
puts "==================================================="
puts "WARNING: Customer still owes $#{tender}! Exiting..."
puts "==================================================="
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment