Created
January 11, 2019 08:09
-
-
Save ChantalDemissie/04c92d7b8b06b565de3848b89f02ea69 to your computer and use it in GitHub Desktop.
Practiceday2.rb
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 | |
puts "please enter a number" | |
number = gets.chomp.to_i | |
if number > 70 | |
puts "passing" | |
else number > 70 | |
puts "not passing" | |
end | |
#2 | |
puts 'please enter a light color' | |
light = gets.chomp | |
if light == 'green' | |
puts 'go' | |
else | |
puts 'stop' | |
end | |
#3 | |
puts "please enter a number" | |
number = gets.chomp.to_i | |
if number.even? | |
puts "even" | |
else | |
puts "odd" | |
end | |
#4 | |
puts "Enter a number" | |
number = gets.chomp.to_i | |
if number % 5 == 0 | |
puts "Multiple of 5" | |
else | |
puts "Not a multiple of 5" | |
end | |
# #5 | |
puts "Pick a number" | |
number = gets.chomp.to_i | |
if number < 10 | |
puts "one digit" | |
elsif number >= 100 | |
puts "three digits" | |
else | |
puts "two digits" | |
end | |
#6 | |
puts "Pick a jersey number" | |
number = gets.chomp.to_i | |
if [12, 71, 80].include? number | |
puts "That number is retired from the seattle seahawks!" | |
end | |
#7 | |
puts "Name a state" | |
state = gets.chomp | |
if ["Washington", "Oregon", "Idaho"].include? state | |
puts "This state is in the PNW" | |
else | |
puts "You should move to the PNW; it's great here!" | |
end | |
#8 | |
size_to_ounces = { | |
"SHORT" => 8, | |
"TALL" => 12, | |
"GRANDE" => 16, | |
"VENTI" => 20, | |
} | |
puts "What size coffee do you want? [#{size_to_ounces.keys.join(', ')}]" | |
coffee = gets.chomp.upcase | |
if size_to_ounces.key?(coffee) | |
puts size_to_ounces[coffee]b | |
end | |
#9 | |
puts "what is your rate of pay?" | |
pay_rate = gets.chomp.to_f | |
puts "how many hours did you work?" | |
hours_worked = gets.chomp.to_i | |
overtime_hours = hours_worked - 40 | |
gross_pay = 0 | |
if hours_worked > 40 | |
gross_pay = pay_rate * hours_worked + 0.5 * pay_rate * overtime_hours | |
else | |
gross_pay = pay_rate * hours_worked | |
end | |
puts "Your gross pay is $#{gross_pay}" | |
#10 | |
puts "what is your rate of pay?" | |
pay_rate = gets.chomp.to_f | |
puts "how many hours did you work?" | |
hours_worked = gets.chomp.to_i | |
overtime_hours = hours_worked - 40 | |
gross_pay = 0 | |
if hours_worked > 60 | |
puts "Please see manager" | |
else | |
if hours_worked > 40 | |
gross_pay = pay_rate * hours_worked + 0.5 * pay_rate * overtime_hours | |
else | |
gross_pay = pay_rate * hours_worked | |
end | |
puts "Your gross pay is $#{gross_pay}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice work!
Here are some comments:
gistfile1.rb
instead ofgistfile1.txt
. You've added Practiceday2.rb to the description of the gist which is not the filename.#
in comments. e.g.# 1
instead of#1
.Slack me if you have any questions.