#include <iostream>
#include <string>
#include "math.h"
int main()
{
usingnamespace std;
int FirstInput, SecondInput, ChoiceInt;
string Choice, ChoiceText;
bool Error = false;
cout << "Please enter the symbol of mathematical process you would like to use...\n";
do {
cin >> Choice;
if (Choice == "*")
{
ChoiceText = "multiplied";
ChoiceInt = 0;
Error = false;
}
elseif (Choice == "+")
{
ChoiceText = "added";
ChoiceInt = 1;
Error = false;
}
elseif (Choice == "-")
{
ChoiceText = "subtracted";
ChoiceInt = 2;
Error = false;
}
elseif (Choice == "/")
{
ChoiceText = "divided";
ChoiceInt = 3;
Error = false;
}
else
{
cout << "Please enter a valid symbol (+, -, *, /)\n";
Error = true;
}
} while (Error == true);
cout << "Now enter a number to be " << ChoiceText << " by another number\n";
cin >> FirstInput;
cout << "Now enter another number...\n";
cin >> SecondInput;
switch (ChoiceInt)
{
case 0: cout << FirstInput << " " << Choice << " " << SecondInput << " = " << multi(FirstInput, SecondInput) << endl;
case 1: cout << FirstInput << " " << Choice << " " << SecondInput << " = " << add(FirstInput, SecondInput) << endl;
case 2: cout << FirstInput << " " << Choice << " " << SecondInput << " = " << sub(FirstInput, SecondInput) << endl;
case 3: cout << FirstInput << " " << Choice << " " << SecondInput << " = " << divide(FirstInput, SecondInput) << endl;
}
cout << "\nPress ENTER to exit\n";
cin.get();
cin.get();
return 0;
}
The program works as it should but when it outputs something it duplicates the answer with different answers (except dividing which works perfectly). Any help would be appreciated.