...

/

Solution: Simple Calculator to Perform Addition

Solution: Simple Calculator to Perform Addition

Go over the Ruby implementation of a simple calculator that performs only addition.

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

  • ...