Ruby - Programming Language
This course covers the basics of programming in Ruby. Work your way through the videos and we'll teach you everything you need to know to start your programming journey!

Calculator

Lesson 19
Author : Mike Dane
Last Updated : November, 2017


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