Hello Le Wagon 👋
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
require_relative 'helpers' | |
# TODO: you can build your christmas list program here! | |
# 1 -> Greet the user (simple puts) | |
puts "\n" | |
puts "*" * 31 | |
puts "*" + " " * 29 + "*" | |
puts "* Welcome to Christmas List *" | |
puts "*" + " " * 29 + "*" | |
puts "*" * 31 |
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
# TODO: you can build your horse race program here! | |
# 1 -> Welcome the user | |
puts "Welcome to the Muenchen horse race!" | |
# while account_balance is greater than or equal to 10 && user_choice == 'y' | |
account_balance = 100 | |
play_again = 'y' | |
while account_balance >= 10 && play_again == 'y' | |
horses = ["Joe the Brave", "Black Stalion", "Ronny the Rat", "Tony Macaroni"] |
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 calculate(number_one, number_two, operator) | |
if operator == "+" | |
number_one + number_two | |
elsif operator == "-" | |
number_one - number_two | |
elsif operator == "*" | |
number_one * number_two | |
elsif operator == "/" | |
number_one / number_two | |
else |
Hello Le Wagon 👋
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 calculate(number_one, number_two, operator) | |
# if operator == '+' | |
# return number_one + number_two | |
# elsif operator == '-' | |
# return number_one - number_two | |
# elsif operator == '/' | |
# return number_one / number_two | |
# elsif operator == '*' | |
# return number_one * number_two | |
# else |
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
puts "Welcome to the Horse Race" | |
puts "How much money do you want to bet?" | |
balance = gets.chomp.to_i | |
answer = 'y' | |
while answer == 'y' && balance >= 10 |
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
# CALCULATOR: | |
# STEP 1: | |
# 1. Ask user for a number - puts | |
# 2. Save it in a variable - gets.chomp | |
# 3. Ask user for second number and save it in a variable | |
# 4. Show user options for operator and ask her to choose one, save it | |
# 5. Calculate what the user chose - if/elsif/else or case operator | |
# 6. Display the result to user - | |
# STEP2: MAKE IT LOOP |
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
# 1. Welcome the user | |
# 2. Define an array of horses | |
horses = [ | |
"Seattle Slew", | |
"Secretariat", | |
"Seabiscuit", | |
"Citation" | |
] | |
# 3. Display horses (with each_with_index) | |
# 1. Joe the Brave |
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
# TODO: you can build your instacart program here! | |
# 1. Greet the user | |
puts "Welcome to the Batch 531 fruit store!" | |
# 2. Model the store as a hash | |
store = {"kiwi" => 2, "apple" => 0.1, "strawberry" => 5, "banana" => 1} | |
# 3. Display what's available in the store, and iterate over the key/value pairs | |
store.each do |fruit, value| | |
puts "#{fruit} - price: $#{value}" | |
end | |
# 4. Initialize an empty shopping cart as an array. |
NewerOlder