-
Notifications
You must be signed in to change notification settings - Fork 7
/
karen-calculator.rb
61 lines (49 loc) · 1.86 KB
/
karen-calculator.rb
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# command
command = ""
while command != "exit".downcase
puts "Hello, I'm a calculator, what would you like to do? To exit please write 'Exit'"
command = gets.chomp.downcase
if command == "add" || command == "+"
puts "What's the first number you would like to add?"
n1 = gets.chomp.to_i
else
puts "Please give me a valid operator (+,-,*,/). What operator would you like to use?"
command = gets.chomp.downcase
puts "What's the first number you would like to add?"
n1 = gets.chomp.to_i
end
#n1 = gets.chomp.to_i
puts "What's the second number you would like to add?"
n2 = gets.chomp.to_i
until (n1 != 0) || (n1.to_s != "0") && (n2 != 0) || (n2.to_s != "0")
puts "One or more of those numbers was not valid, please enter numbers only"
n1 = gets.chomp.to_i
n2 = gets.chomp.to_i
end
puts "#{n1} + #{n2} = #{n1 + n2}"
if command == "subtract" || command == "-"
puts "What's your first number?"
n1 = gets.chomp.to_i
else
puts "Please give me a valid operator (+,-,*,/). What operator would you like to use?"
command = gets.chomp.downcase
end
puts "What's your second number"
n2 = gets.chomp.to_i
puts "#{n1} - #{n2} = #{n1 - n2}"
if command == "multiply" || command == "*" || command == "x"
puts "What's the first number you would like to multiply?"
n1 = gets.chomp.to_i
puts "What's the second number you would like to multiply?"
n2 = gets.chomp.to_i
puts "#{n1} * #{n2} = #{n1 * n2}"
end
if command == "divide" || command == "/"
puts "What's your first number"
n1 = gets.chomp.to_i
puts "What's your second number"
n2 = gets.chomp.to_i
puts "#{n1} * #{n2} = #{n1 * n2}"
end
end
puts "I'm tired. Adios bitchachos."