Hello, I am trying to create a simple menu using multiple if statements. I am not getting the results I am looking for. When I run my program, I am trying to enter the menuChoice (a,b,c,d,e) and have the output show the correct number in the initialInvestment variable. Can somebody please explain what I am doing incorrectly. Thanks in advance
int main()
{
// Program Variables
char menuChoice;
float initialInvestment = 0;
int yearsToInvest = 0;
float interestRate = 0;
float finalAmount = 0;
float interestEarned = 0;
float timeToDoubleInvestment = 0;
// Get Investment Amount - Display Menu Options
cout << "Choose Investment Amount" << endl;
cout << "------------------------" << endl;
cout << " A ....... 5000" << endl;
cout << " B ....... 10000" << endl;
cout << " C ....... 15000" << endl;
cout << " D ....... 20000" << endl;
cout << " E ....... 25000" << endl;
cout << "------------------------" << endl;
cout << " Enter option A-E: ";
cin >> menuChoice;
// Determine initial investment based on menu choice input
// Use 5000 for an invalid response
if (menuChoice == 'a' || 'A')
{
initialInvestment = 5000;
}
if (menuChoice == 'b' || 'B')
{
initialInvestment = 10000;
}
if (menuChoice == 'c' || 'C')
{
initialInvestment = 15000;
}
if (menuChoice == 'd' || 'D')
{
initialInvestment = 20000;
}
if (menuChoice == 'd' || 'D')
{
initialInvestment = 25000;
}
else
{
initialInvestment = 5000;
}
cout << initialInvestment;
return 0;
}
EDIT: When I do run the program, and for example I enter C for the menuChoice variable, th answer will always come out as 25000, when it is supposed to be 15000.. I do not know how to fix this error, which I feel is very simple but I can not fix. I was instructed to not use an if-else if statement. But if that is the only way to fix, please mention that and explain why. Thanks.