Calculator

Lesson 19
Author : Afrixi
Last Updated : November, 2017


Table of Content

Code

Copyputs "num1: "
num1 = gets.chomp.to_f

puts "Enter Operator: "
op = gets.chomp

puts "num2: "
num2 = gets.chomp.to_f

if op == "+"
     puts num1 + num2
elsif op == "-"
     puts num1 - num2
elsif op == "/"
     puts num1 / num2
elsif op == "*"
     puts num1 * num2
else
     puts "Invalid Operator"
end