Skip to content

Instantly share code, notes, and snippets.

@justuseapen
Last active December 28, 2015 08:19
Show Gist options
  • Save justuseapen/7470442 to your computer and use it in GitHub Desktop.
Save justuseapen/7470442 to your computer and use it in GitHub Desktop.
LIGHT = 5.00
MEDIUM = 7.50
BOLD = 9.75
def coffee_selection
puts "How many packs of LIGHT would the customer like?"
light_total = LIGHT*gets.chomp.to_f
puts "How many packs of MEDIUM would the customer like?"
medium_total = MEDIUM*gets.chomp.to_f
puts "How many packs of BOLD would the customer like?"
bold_total = BOLD*gets.chomp.to_f
amount_due = light_total + medium_total + bold_total
puts "The total amount due is $#{"%.2f" % amount_due}."
puts "How much money has the customer given you?"
cash_rendered = gets.chomp.to_f
if cash_rendered < amount_due
puts "That is not enough money!"
else
change = cash_rendered - amount_due
change_time = Time.now.strftime("%I:%M%P %B %d %Y")
puts "You owe the customer $#{"%.2f" % change} in change at #{change_time}"
end
end
coffee_selection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment