I'm trying to make a basic four-function calculator, and it seems to be working just fine... except when testing it, whenever I try multiplication the numbers seem to come back divided, not multiplied. I can't see anything wrong with my code, but clearly there's something... anyone see it? Thanks.
#include<iostream>
usingnamespace std;
int main()
{
float firstNumber, secondNumber, result;
char operation;
// Getting input from user
cout << "Please enter the first number.";
cout << endl;
cin >> firstNumber;
cout << "Please enter the second number.";
cout << endl;
cin >> secondNumber;
cout << "Please enter a single character to indicate the operation.";
cout << endl;
cin >> operation;
// Doing calculations
switch (operation)
{
case'a':
result = firstNumber+secondNumber;
cout << endl;
case'A':
result = firstNumber+secondNumber;
case's':
result = firstNumber-secondNumber;
case'S':
result = firstNumber-secondNumber;
case'm':
result = firstNumber*secondNumber;
case'M':
result = firstNumber*secondNumber;
case'd':
result = firstNumber/secondNumber;
case'D':
result = firstNumber/secondNumber;
}
// Output of result
cout << result;
cout << endl;
return 0;
}