Solution: Simple Calculator to Perform Addition
Understand how to build a simple Ruby calculator that takes user inputs from the command line, converts them to integers, and displays the addition result using string interpolation.
We'll cover the following...
We'll cover the following...
Solution
puts "I am an Adding Machine and I am good at it"
puts "Enter first number:"
num1 = gets.chomp.to_i
puts "Enter second number:"
num2 = gets.chomp.to_i
puts "Thinking..."
answer = num1 + num2
puts "Got it, the answer is: #{answer}"Solution for a simple calculator
Explanation
...