Create a simple calculator and pass all the tests. The choice, x, and y are all given to you as ints. Just figure out how to fix the rest.
#include <iostream>
using namespace std;
string die() {
return "Invalid Input!";
}
string Calculator(int choice, int x, int y) {
cout << "Welcome to simple calculator!\n";
cout << "1. Addition\n2. Subtraction\n3. Multiplication\n4. Division\n5. Modulus\n";
// YOU: Write code to finish this program (Input is given, don't use cin)
// Instead of cout << x + y << endl; for example, do return (x + y);
// You can call the die function with die();
}
// TODO: Replace examples and use TDD by writing your own tests
Describe(Sample_Tests)
{
It(Test)
{
Assert::That(Calculator(0, 420, 420), Equals("Invalid Input!"));
Assert::That(Calculator(1, 1, 1), Equals("2"));
Assert::That(Calculator(1, 16, 9), Equals("25"));
Assert::That(Calculator(2, 1, 1), Equals("0"));
Assert::That(Calculator(2, 57, 62), Equals("-5"));
Assert::That(Calculator(3, -10, 10), Equals("-100"));
Assert::That(Calculator(3, -12, -12), Equals("144"));
Assert::That(Calculator(4, 2, 4), Equals("0"));
Assert::That(Calculator(4, 4, 2), Equals("2"));
Assert::That(Calculator(4, 1, 0), Equals("Invalid Input!"));
Assert::That(Calculator(5, 3, 5), Equals("3"));
Assert::That(Calculator(5, 5, 3), Equals("2"));
Assert::That(Calculator(6, 69, 69), Equals("Invalid Input!"));
}
};