Created
April 30, 2019 07:11
-
-
Save SajidK25/5655ec73b4ef5d9cb7a9e08d3790bd54 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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