So I'm using atom to code up a calculator and I can't seem to get the console to output the first instance of puts. It just says [Finished in 2.88s]. Is there anything missing that's causing my code to not be printed to the console or am I just stupid to think that it should be outputting anything to the console? Here is my code:
def add
puts "What is the first number to be added?"
n1 = gets.chomp
puts "What is the second number to be added?"
n2 = gets.chomp
answer = n1 + n2
puts "Congrats, your number is #{answer}"
end
def sub
puts "What is the first number to be subtracted?"
n1 = gets.chomp
puts "What is the second number to be subtracted?"
n2 = gets.chomp
answer = n1 - n2
puts "Congrats, your number is #{answer}"
end
def multiply
puts "What is the first number to be multiplied?"
n1 = gets.chomp
puts "What is the second number to be multiplied?"
n2 = gets.chomp
answer = n1 * n2
puts "Congrats, your number is #{answer}"
end
def divide
puts "What is the first number to be divided?"
n1 = gets.chomp
puts "What is the second number to be divided?"
n2 = gets.chomp
answer = n1 / n2
puts "Congrats, your number is #{answer}"
end
print "Would you like to add, subtract, multiply, or divide a number? "
response = gets.chomp
if response == "add" then
add
elsif response == "subtract" then
sub
elsif response == "multiply" then
multiply
else response == "divide"
divide
end