-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstyle.rb
More file actions
47 lines (44 loc) · 904 Bytes
/
Copy pathstyle.rb
File metadata and controls
47 lines (44 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# # good style
# # prints the numbers 1 to 10
# (1..10).each do |num|
# puts num
# end
# # good style
# print "Enter an animal: "
# animal = gets.chomp
# if animal == "Fish"
# puts "Wonderful in the Water!"
# elsif animal == "Camel"
# puts "Destination Desert!"
# else
# puts "Worldwide Wonder!"
# end
# # good style
# # sum the numbers 1 to 10
# total = 0
# (1..10).each do |i|
# total = total + i
# end
# # prints a message based on sum
# if total > 10
# puts "More than ten"
# else
# puts "Less than ten"
# end
#
# good style
print "Enter your username: "
username = gets.chomp
print "Enter your password: "
password = gets.chomp
# prints welcome message if correct username
# and password. Otherwise, prints error message
if username == "foo"
if password == "bar"
puts "Welcome, administrator!"
else
puts "Incorrect password."
end
else
puts "Incorrect username."
end