hai. anyone can help me ? I run my coding but it be invalid option even I already declare my coding. Can I know which part I wrong ?
#include <iostream>
#include <string>
using namespace std;
void printintromenu();
void login();
void mainmenu();
int main ()
{
cout << "Welcome To ZS ATM" << endl << endl;
char intro;
cout << " ******************Welcome to ZS's ATM Machine*****************" << endl;
cout << "l) Login" << endl;
cout << "q) Quit" << endl;
cin >> intro;
if (intro=='l')
{
login();
mainmenu();
}
else if (intro=='q')
{
cout << "You have quit the program" << endl;
}
mainmenu();
return 0;
}
void login ()
{
string id;
string password;
bool loginSuccess = false;
do
{
cout << "\n\nPlease enter your user id: " << endl;
cin >> id;
cout << "\n\nPlease enter your password: " << endl;
cin >> password;
if (id == "zurena" && password == "zurena")
{
cout << " Successful Login ";
loginSuccess = true;
}
else
{
cout << "**********LOGIN FAILED!**********\n\n";
cout << "Please try to login again" << endl;
}
}
while (!loginSuccess);
}
void mainmenu ()
{
char option;
float balance, amount,withdraw;
balance=0;
//Prompting user to select account type
cout << "Access Granted ! " << endl;
//Display account operations options to user
cout << "d) Deposit Money" << endl;
cout << "w) Withdraw Money" << endl;
cout << "r) Request Balance" << endl;
cout << "q) Quit" << endl;
cout << "Select an option: ";
cin >> option;
//prompt user to select operation
while (option!='d'|| option!='w' || option!='r' )
{
if (option == 'd') // User want to Deposit money
{
cout << "Please enter amount to deposit ";
cin >> amount;
balance=balance+amount;
cout << " The deposit amount you had entered is: RM" << amount << endl;
}
else if (option=='r')
{
cout << "Your balance is: RM " << balance << endl;
}
else if(option == 'w') // User want to Withdraw money
{
//prompt user to enter amount he/she want to Withdraw money
cout << "Please enter amount to withdraw ";
cin >> withdraw;
balance=balance-withdraw;
cout << "You had withdraw: RM" << withdraw << endl;
}
cout << "Invalid Option Selected. Please select the option given" << endl;
cin >> option;
}
}