The login and new account feature are not working properly. I
wanted to know how to fix this because every time I try to login or
create an account it tells me login failed.
#include <iostream>
#include <string>
#include <iomanip>
#include <stdio.h>
using namespace std;
class Howard_COP2513_F1601
{
public:
char userInput;
char userInput2;
string id;
string password;
string ID;
string PASSWORD;
double DEPOSIT;
double WITHDRAW;
double OLDBALANCE;
double NEWBALANCE;
Howard_COP2513_F1601()
{
userInput = ‘ ‘;
userInput2 = ‘ ‘;
id = “?”;
password = “?”;
ID = “?”;
PASSWORD = “?”;
DEPOSIT = 0.00;
WITHDRAW = 0.00;
OLDBALANCE = 0.00;
NEWBALANCE = 0.00;
}
void bankOption()
{
cout << “Please select an
option: ” << endl;
cout << “l -> Login ”
<< endl;
cout << “c -> Create New
Account ” << endl;
cout << “q -> Quit ”
<< endl;
cin >> userInput;
if (userInput == ‘l’ ||
‘L’)
{
login();
}
else if (userInput == ‘c’ ||
‘C’)
{
createAcnt();
}
else if (userInput == ‘q’ ||
‘Q’)
{
quit();
}
}
void moneyOption()
{
cout << “d -> Deposit
Money ” << endl;
cout << “w -> Withdraw
Money ” << endl;
cout << “r -> Request
Balance” << endl;
cout << “q -> Quit ”
<< endl;
cin >> userInput2;
if (userInput2 == ‘d’ ||
userInput2 == ‘D’)
{
dMoney();
}
else if (userInput2 == ‘w’ ||
userInput2 == ‘W’)
{
wMoney();
}
else if (userInput2 == ‘r’ ||
userInput2 == ‘R’)
{
rBalance();
}
else if (userInput == ‘q’ ||
‘Q’)
{
quit();
}
fflush(stdin);
}
int login()
{
cout << “Please enter your
user id: ” << endl;
cin >> ID;
cout << “Please enter your
password: ” << endl;
cin >> PASSWORD;
if (id == ID && password ==
PASSWORD)
{
cout <<
“Access Granted – ” << ID << endl;
moneyOption();
}
else
{
cout <<
“******** ” << “LOGIN FAILED! ” << “********” <<
endl;
bankOption();
}
return 0;
}
int createAcnt()
{
cout << “Please enter your
user name: ” << endl;
cin >> ID;
cout << “Please enter your
password: ” << endl;
cin >> PASSWORD;
ID = ID;
PASSWORD = PASSWORD;
bankOption();
return 0;
}
int quit()
{
cout << “Thanks for banking
with COP2513.F16,” << ID << “!” << endl;
system(“pause”);
return 0;
}
int dMoney()
{
cout << “Amount of deposit: ”
<< endl;
cin >> DEPOSIT;
OLDBALANCE = NEWBALANCE;
NEWBALANCE = OLDBALANCE +
DEPOSIT;
moneyOption();
return 0;
}
int wMoney()
{
cout << “Amount of
withdrawal: ” << endl;
cin >> WITHDRAW;
OLDBALANCE = NEWBALANCE;
NEWBALANCE = OLDBALANCE –
WITHDRAW;
moneyOption();
return 0;
}
int rBalance()
{
cout << “Beginning
balance: ” << “$ ” << fixed << setprecision(2)
<< OLDBALANCE << endl;
cout << “Deposit amount: ”
<< “$ ” << fixed << setprecision(2) <<
DEPOSIT << endl;
cout << “Withdrawal amount: ”
<< “$ ” << fixed << setprecision(2) <<
WITHDRAW << endl;
cout << “Your Balance is: ”
<< “$ ” << fixed << setprecision(2) <<
NEWBALANCE << endl;
cout << endl;
moneyOption();
return 0;
}
};
int main()
{
Howard_COP2513_F1601 obj1;
obj1.bankOption();
return 0;
}
Tony SparkEnlightened
Here is the modified version for you:

#include <iostream>
#include <string>
#include <iomanip>
#include <stdio.h>
using namespace std;
class Howard_COP2513_F1601
{
public:
char userInput;
char userInput2;
string id;
string password;
string ID;
string PASSWORD;
double DEPOSIT;
double WITHDRAW;
double OLDBALANCE;
double NEWBALANCE;
Howard_COP2513_F1601()
{
userInput = ‘ ‘;
userInput2 = ‘ ‘;
id = “?”;
password = “?”;
ID = “?”;
PASSWORD = “?”;
DEPOSIT = 0.00;
WITHDRAW = 0.00;
OLDBALANCE = 0.00;
NEWBALANCE = 0.00;
}
void bankOption()
{
cout << “Please select an option: ” << endl;
cout << “l -> Login ” << endl;
cout << “c -> Create New Account ” << endl;
cout << “q -> Quit ” << endl;
cin >> userInput;
if (userInput == ‘l’ || userInput == ‘L’)
{
login();
}
else if (userInput == ‘c’ || userInput == ‘C’)
{
createAcnt();
}
else if (userInput == ‘q’ || userInput == ‘Q’)
{
quit();
}
}
void moneyOption()
{
cout << “d -> Deposit Money ” << endl;
cout << “w -> Withdraw Money ” << endl;
cout << “r -> Request Balance” << endl;
cout << “q -> Quit ” << endl;
cin >> userInput2;
if (userInput2 == ‘d’ || userInput2 == ‘D’)
{
dMoney();
}
else if (userInput2 == ‘w’ || userInput2 == ‘W’)
{
wMoney();
}
else if (userInput2 == ‘r’ || userInput2 == ‘R’)
{
rBalance();
}
else if (userInput2 == ‘q’ || userInput2 == ‘Q’)
{
quit();
}
fflush(stdin);
}
int login()
{
cout << “Please enter your user id: ” << endl;
cin >> id;
cout << “Please enter your password: ” << endl;
cin >> password;
if (id == ID && password == PASSWORD)
{
cout << “Access Granted – ” << ID << endl;
moneyOption();
}
else
{
cout << “******** ” << “LOGIN FAILED! ” <<
“********” << endl;
bankOption();
}
return 0;
}
int createAcnt()
{
cout << “Please enter your user name: ” << endl;
cin >> id;
cout << “Please enter your password: ” << endl;
cin >> password;
ID = id;
PASSWORD = password;
bankOption();
return 0;
}
int quit()
{
cout << “Thanks for banking with COP2513.F16,” << ID
<< “!” << endl;
system(“pause”);
return 0;
}
int dMoney()
{
cout << “Amount of deposit: ” << endl;
cin >> DEPOSIT;
OLDBALANCE = NEWBALANCE;
NEWBALANCE = OLDBALANCE + DEPOSIT;
moneyOption();
return 0;
}
int wMoney()
{
cout << “Amount of withdrawal: ” << endl;
cin >> WITHDRAW;
OLDBALANCE = NEWBALANCE;
NEWBALANCE = OLDBALANCE – WITHDRAW;
moneyOption();
return 0;
}
int rBalance()
{
cout << “Beginning balance: ” << “$ ” << fixed
<< setprecision(2) << OLDBALANCE << endl;
cout << “Deposit amount: ” << “$ ” << fixed
<< setprecision(2) << DEPOSIT << endl;
cout << “Withdrawal amount: ” << “$ ” << fixed
<< setprecision(2) << WITHDRAW << endl;
cout << “Your Balance is: ” << “$ ” << fixed
<< setprecision(2) << NEWBALANCE << endl;
cout << endl;
moneyOption();
return 0;
}
};
int main()
{
Howard_COP2513_F1601 obj1;
obj1.bankOption();
return 0;
}
And the output screenshot is:
《 Terminal Shell Edit View Window Help < > 4)) 98% (ED Sat 26 Nov 02:07 ANANDA KUMAR THUMMAPUDI a e E cheggCPP-a.outー80x 31 Currently Open Docum… FooFunction.c… HowardIDPass.. untitled text 4…. ggCPP/HowardIDPassword.cpp. /cheggCPP-a.out 29 30 OLDBALANCE 0.00 NEWBALANCE 0.00 Macintosh:cheggCPP AnandaKumarThummapudis g++ HowardIDPassword.cpp Macintosh: cheggCPP AnandaKumarThummapudi$ ./a.out Please select an option: L ->Login c – Create New Account qQuit void bankOption() cout << “Please select an option: “<<endl; cout <<“-Login ” << endl; cout << “С-> Create New Account ” endl; cout <<“qQuit “<<endl; cin >userInput; if (userInput’ userInput ‘L’ Please enter your user name: Kumar Please enter your password: kumar Please select an option: L -Login c-> Create New Account qQuit 40 41 login); else if (userInputc userInput’C) Please enter your user id: Kumar createAcnt); Please enter your password: else if (userInput q’1 userInput’Qkmar Access Granted- Kumar d -Deposit Money w ->Withdraw Money r -Request Balance qQuit 49 quit); void moneyoption(0) int login() cout << “Please enter your user id: ” <<endl; cin >id cout << “Please enter your password: ” << endl; cin password; if (idID && password PASSWORD) 80 cout << “Access Granted – << ID << endl; money0ption(); 86 else cout <<“o<“LOGIN FAILED! “<<<< endl; bank0ption(); return ; int createAcnt ) 95 96 97 98 cout << “Please enter your user name: “<<endl; cin >> id;