Created
January 11, 2019 08:23
-
-
Save ChantalDemissie/389a8234a38efb45568090a129a84b22 to your computer and use it in GitHub Desktop.
candy machine
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
#introduction to user of candy machine program | |
puts "Welcome to Chantals ~New Orleans Sweets Machine~ \n How much money do you have?" | |
money = gets.chomp.to_f | |
puts "\n" | |
puts "That $#{money} sounds about right in this economy, here are your options!" | |
puts "A: $5.00 Bananas Foster" | |
puts "B: $3.00 Beignet" | |
puts "C: $4.50 Bread Pudding" | |
puts "D: $2.50 Praline" | |
candy_choice =gets.chomp.upcase | |
if candy_choice == "A" | |
candy_choice = 5.00 | |
elsif candy_choice == "B" | |
candy_choice = 3.00 | |
elsif candy_choice == "C" | |
candy_choice = 4.50 | |
elsif candy_choice == "D" | |
candy_choice = 2.50 | |
end | |
change = money - candy_choice | |
puts "\n" | |
if change > 0 | |
puts "Enjoy the sweets! and take your $#{change} change" | |
else | |
puts "No imported sweets for you! go buy some produce around the corner if you only have $#{money}! " | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nicely done!
Here are some thoughts for further improvement:
=
in line 11.