Im a college student so I made a simple calculator using functions, and its working. but after i put the 2 numbers in, it wouldn't let me choose what option i wanted to choose. i also got a WARNING C4715, but the code still runs properly... I tried reversing the order of the code, but obviously that failed. can anyone help :( ???
CODE:
#include<iostream>
using namespace std;
double operation(double num1, double num2)
{
cout << "Press 1 for addition" << endl;
cout << "Press 2 for subtraction" << endl;
cout << "Press 3 for multiplication" << endl;
cout << "Press 4 for division" << endl;
cout << "Press 5 for raise to the power of x" << endl;
cout << "Press 6 for Even or Odd" << endl;
cout << "Press 7 for Quit" << endl;
int Option{};
switch (Option)
{
case 1:
{
return num1 + num2;
cout << "The total sum = " << num1 + num2 << endl;
}
break;
case 2:
{
return num1 - num2;
cout << "The total differencr = " << num1 - num2 << endl;
}
break;
case 3:
{
return num1 * num2;
cout << "The total product = " << num1 * num2 << endl;
}
break;
case 4:
{
return num1 / num2;
cout << "The total quotient = " << num1 / num2 << endl;
}
break;
case 5:
{
double x = num1;
cout << pow(x, num2);
cout << "The Number of" << x << " raised to the power of" << num2 << "is" << pow(x, num2) << endl;
}
break;
case 6:
{int num1{};
if (num1 % 2 == 0)
cout << "The Number Is EVEN.";
else
cout << "The Number Is ODD";
}
break;
case 7:
{
cout << "You are now Leaving the Calculator, GOODBYE !!! " << endl;
}
break;
default:
{
cout << "Invalid Entry!\nPlease re-run the program and " << endl;
cout << "enter a valid menu choice.\n";
}
break;
}
}
int main()
{
double num1, num2;
cout << "Enter a value for num1: " << endl;
cin >> num1;
cout << "Enter a second value for num2: " << endl;
cin >> num2;
double store = operation(num1, num2);
system("pause");
return 0;
}