You have been tasked with creating a program that runs in the command line (bash). The program should ask for 2 numbers, a mathematical operator, and then execute the operation on the two numbers.
- Can be run using bash (i.e.
ruby yourfile.rb
) - Asks the user to input a number (i.e.
10
) - Asks the user to input another number (i.e.
5
) - Asks the user to input a mathematical operator (i.e.
+
) - Outputs the the result of the computation (i.e.
15.0
) - The user should have the option to perform another computation, or exit the program
- Only accept integers (and error gracefully if the user inputs anything else)
- Only accept valid mathematical operators (and error gracefully if something else is inputted)
- Output floats (numbers with decimals)
- Have a class called
Calculator
- Your class should have instance methods that perform each type of computation (i.e. addition, subtraction, etc)
- Only create once instance of the
Calculator
class (no matter how many computations the user does)
Enter a number:
5
Enter another number:
5
Enter a mathematical operator:
+
5 + 5 = 10
Would you like to perform another calculation? (y/n)
...