Coding Exercises

Build a Prefix Notation Calculator in Ruby

Building a calculator is a popular interview question and a good approach for learning a programming language. In this guide we’re going to build a Prefix Notation calculator in Ruby, which enables users to enter an operator, followed by any set of numbers to calculate.

Summary

Build a Prefix Notation Calculator in Ruby.

Exercise File

Code File

Exercise Description

Build a method that performs addition, subtraction, multiplication, and division on any number of values passed to the method. Additionally, ensure to handle improperly entered requests (bonus points if you build your own error handling class).

Real World Usage

This is a popular interview coding question since it requires developers to showcase skill when it comes to working with mathematical calculations in Ruby. Additionally, it offers a number of potential implementation options, including a wide range of options when it comes to managing improper input from users.

Solution

Can be found on the solutions branch on github.

Jordan Hudgens
the authorJordan Hudgens

Leave a Reply