Skip to content

Instantly share code, notes, and snippets.

@SajidK25
Created April 30, 2019 07:11
Show Gist options
  • Save SajidK25/5655ec73b4ef5d9cb7a9e08d3790bd54 to your computer and use it in GitHub Desktop.
Save SajidK25/5655ec73b4ef5d9cb7a9e08d3790bd54 to your computer and use it in GitHub Desktop.
def addition_function
puts "Which numbers would you like to add?"
@n1 = gets.chomp
@n2 = gets.chomp
@answer = @n1 + @n2
# @n1 + @n2 == @answer
puts "The sum is... #{@answer}"
end
def subtraction_function
puts "Which numbers would you like to subtract?"
@n1 = gets.chomp.to_i
@n2 = gets.chomp.to_i
@n1 - @n2 == @answer
puts "The answer is... #{@answer}"
end
def multiplication_function
puts "Which numbers would you like to multiply?"
@n1 = gets.chomp
@n2 = gets.chomp
@n1 * @n2 == @answer
puts "The answer is... #{@answer}"
end
puts "Would you like to [add], [multiply], or [subtract]?"
response = gets.chomp
if response == "add" then
addition_function
end
if response == "subtract" then
subtraction_function
end
if response == "multiply" then
multiplication_function
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment