C only please in this assignment you are to create an intera

C++ only please, in this assignment you are to create an interactive line command driven C++ program that allows a user to do the following:

1) Create a bank account by supplying a user id and password

2) Login using this id and password

3) Quit the program

Upon successful login, the user will be presented with a menu to do one or more of the following actions:

1) Withdraw money 2) Deposit money 3) Request balance 4) Quit the program

Ensure that you remove any unnecessary punctuation from monetary input (for example, all $ or other currency symbols should be removed prior to processing, do NOT display an error message to the user for characters which can be removed from the input string without changing the intended value).

Format all monetary outputs on the display Currency (e.g. $ 25,928.43) with all decimal places containing digits.

The User ID and password fields may be any combination of characters which are: 1) Visible when displayed on the screen (no control characters0
2) Normally accessible from a standard US keyboard

Separate your code into multiple functions, demonstrating good programming practices.

If login was not successful (for example the id or password did not match) then the user must be returned to the introduction menu.

Submit the following as a file (screen capture) to demonstrate your program in action. Items in BOLD are user input:

Welcome to My Bank ATM Machine

          Please select an option:

l -> Login

c -> Create New Account

q -> Quit

> l

Please enter your user id: QTL7Zark7

Please enter your password B1rdGo!

******** LOGIN FAILED! ********

Please select an option from the menu below:

l -> Login

c -> Create New Account

q -> Quit

> c

Please enter your user name: Y0ro1den!

Please enter your password: S@murA1

Thank You! Your account has been created!

l -> Login

c -> Create New Account

q -> Quit

> l

Please enter your user name: Y0ro1den!

Please enter your password: S@murA1

Access Granted - Y0ro1den!

d -> Deposit Money

w -> Withdraw Money

r -> Request Balance

> d

Amount of deposit: $2056.45

d -> Deposit Money

w -> Withdraw Money

r -> Request Balance

> r

Beginning balance : $ 0.00

Deposit amount : $ 2,056.45

Your balance is : $ 2,056.45

d -> Deposit Money

w -> Withdraw Money

r -> Request Balance

> d

Amount of deposit: 56.45

d -> Deposit Money

w -> Withdraw Money

r -> Request Balance

> r

Beginning balance : $ 2,056.45

Deposit amount : $ 56.45

Your balance is $ 2,112.90

d -> Deposit Money

w -> Withdraw Money

r -> Request Balance

> w

Amount of withdrawal: -2.5

d -> Deposit Money

w -> Withdraw Money

r -> Request Balance

> r

Beginning balance : $ 2,112.90

Withdrawal amount : $( 2.50)

Your balance is $ 2,115.40

d -> Deposit Money

w -> Withdraw Money

r -> Request Balance

> w

Amount of withdrawal: 125.57

d -> Deposit Money

w -> Withdraw Money

r -> Request Balance

> r

Beginning balance : $ 2,115.40

Withdrawal amount : $ 125.57

Your balance is $ 1,989.83

d -> Deposit Money

w -> Withdraw Money

r -> Request Balance

> q

Thanks for banking with My Bank, Y0ro1den!!

Welcome to My Bank ATM Machine

          Please select an option:

l -> Login

c -> Create New Account

q -> Quit

> l

Please enter your user id: QTL7Zark7

Please enter your password B1rdGo!

******** LOGIN FAILED! ********

Please select an option from the menu below:

l -> Login

c -> Create New Account

q -> Quit

> c

Please enter your user name: Y0ro1den!

Please enter your password: S@murA1

Thank You! Your account has been created!

l -> Login

c -> Create New Account

q -> Quit

> l

Please enter your user name: Y0ro1den!

Please enter your password: S@murA1

Access Granted - Y0ro1den!

d -> Deposit Money

w -> Withdraw Money

r -> Request Balance

> d

Amount of deposit: $2056.45

d -> Deposit Money

w -> Withdraw Money

r -> Request Balance

> r

Beginning balance : $ 0.00

Deposit amount : $ 2,056.45

Your balance is : $ 2,056.45

d -> Deposit Money

w -> Withdraw Money

r -> Request Balance

> d

Amount of deposit: 56.45

d -> Deposit Money

w -> Withdraw Money

r -> Request Balance

> r

Beginning balance : $ 2,056.45

Deposit amount : $ 56.45

Your balance is $ 2,112.90

d -> Deposit Money

w -> Withdraw Money

r -> Request Balance

> w

Amount of withdrawal: -2.5

d -> Deposit Money

w -> Withdraw Money

r -> Request Balance

> r

Beginning balance : $ 2,112.90

Withdrawal amount : $( 2.50)

Your balance is $ 2,115.40

d -> Deposit Money

w -> Withdraw Money

r -> Request Balance

> w

Amount of withdrawal: 125.57

d -> Deposit Money

w -> Withdraw Money

r -> Request Balance

> r

Beginning balance : $ 2,115.40

Withdrawal amount : $ 125.57

Your balance is $ 1,989.83

d -> Deposit Money

w -> Withdraw Money

r -> Request Balance

> q

Thanks for banking with My Bank, Y0ro1den!!

Solution

Here is the code for the question.

#include <iostream>
#include <cstring>
#include <locale.h>
#include <iomanip>
using namespace std;
//displays the menu corresponding to menuNum. If 1 then main menu is displayed
//otherwise menu after login is displayed. The user\'s selection is returned
char printMenu(int menuNum)
{
char option;
//display main menu
if(menuNum==1)
{
cout<<\"\\t\\tl -> Login\"<<endl;
cout<<\"\\t\\tc -> Create Account\"<<endl;
cout<<\"\\t\\tq -> Quit\"<<endl;
}
else //menu after login
{
cout<<\"\\t\\td -> Deposit Money\"<<endl;
cout<<\"\\t\\tw -> Withdraw Money\"<<endl;
cout<<\"\\t\\tr -> Request Balance\"<<endl;
cout<<\"\\t\\tq -> Quit\"<<endl;
}
cout<<\"\\tPlease select an option: \";
cin>>option;
return tolower(option);
}
//the user is asked to enter username and password and the parameters are references
//so it gets updated in main function
void create(string &username,string &password)
{
//get the credentials from user and save it in username and password
cout<<\"\\tPlease enter your user id: \";
cin>>username;
cout<<\"\\tPlease enter your password:\";
cin>>password;
cout<<\"\\tThank you! Your account has been created!\"<<endl;
}
//ask user for name and password and compare them to already created values
//return true if login passed otherwise returns false
bool login(const string &username,const string &password)
{
string uid,pwd;
//get user name and password from user
cout<<\"\\tPlease enter your user id: \";
cin>>uid;
cout<<\"\\tPlease enter your password:\";
cin>>pwd;
if(uid==username && pwd==password)
{
cout<<\"\\tAccess Granted! - \"<<uid<<endl;
return true;
}
else
{
cout<<\"\\t***** Login Failed! *****\"<<endl;
return false;
}
}


int main()
{
string username,password; //the username and password that is created
string uid,pwd; //the values used during login
char option,last_transaction=\' \';
bool repeat=true;
int menuNum=1;
double balance=0,deposit,withdrawal,prevbalance=0;
cout<<\"\\tWelcome to My Bank ATM Machine\"<<endl;

while(repeat)
{
option=printMenu(menuNum);
switch(tolower(option))
{
case \'l\':
if(login(username,password))
menuNum=2; //change menu number if login is succesful
break;
case \'c\':
create(username,password);
break;
case \'d\':
cout<<\"\\tAmount of deposit: \";
cin>>deposit;
prevbalance=balance;
balance=balance+deposit;
last_transaction=\'d\';
break;
case \'r\':
//format the output with comma and show 2 decimal places
cout.imbue(std::locale(\"\"));
cout<<\"\\tBeginning Balance: $\"<<std::fixed<<setprecision(2)<<prevbalance<<endl;
if(last_transaction==\'d\')
cout<<\"\\tDeposit Amount: $\"<<deposit<<endl;
else
{
if(withdrawal < 0) //-ve Amount
cout<<\"\\tWithdrawal Amount: $(\"<<withdrawal<<\")\"<<endl;
else
cout<<\"\\tWithdrawal Amount: $\"<<withdrawal<<endl;

}
cout<<\"\\tYour balance is $\"<<balance<<endl;
break;
case \'w\':
cout<<\"\\tAmount of withdrawal: \";
cin>>withdrawal;
prevbalance=balance;
balance=balance-withdrawal;
last_transaction=\'w\';
break;
case \'q\':
cout<<\"\\tThank you for banking with My Bank\";
if(username.empty())
cout<<\"!\"<<endl;
else
cout<<\", \"<<username<<\"!\"<<endl;
repeat=false;
break;
}


}
return 0;
}

output

Welcome to My Bank ATM Machine
       l -> Login
       c -> Create Account
       q -> Quit
   Please select an option: l
   Please enter your user id: test
   Please enter your password:test
   ***** Login Failed! *****
       l -> Login
       c -> Create Account
       q -> Quit
   Please select an option: c
   Please enter your user id: test
   Please enter your password:testp
   Thank you! Your account has been created!
       l -> Login
       c -> Create Account
       q -> Quit
   Please select an option: l
   Please enter your user id: test
   Please enter your password:testp
   Access Granted! - test
       d -> Deposit Money
       w -> Withdraw Money
       r -> Request Balance
       q -> Quit
   Please select an option: d
   Amount of deposit: 2039.45
       d -> Deposit Money
       w -> Withdraw Money
       r -> Request Balance
       q -> Quit
   Please select an option: r
   Beginning Balance: $0.00
   Deposit Amount: $2,039.45
   Your balance is $2,039.45
       d -> Deposit Money
       w -> Withdraw Money
       r -> Request Balance
       q -> Quit
   Please select an option: w
   Amount of withdrawal: 39
       d -> Deposit Money
       w -> Withdraw Money
       r -> Request Balance
       q -> Quit
   Please select an option: r
   Beginning Balance: $2,039.45
   Withdrawal Amount: $39.00
   Your balance is $2,000.45
       d -> Deposit Money
       w -> Withdraw Money
       r -> Request Balance
       q -> Quit
   Please select an option: d
   Amount of deposit: 19
       d -> Deposit Money
       w -> Withdraw Money
       r -> Request Balance
       q -> Quit
   Please select an option: r
   Beginning Balance: $2,000.45
   Deposit Amount: $19.00
   Your balance is $2,019.45
       d -> Deposit Money
       w -> Withdraw Money
       r -> Request Balance
       q -> Quit
   Please select an option: w
   Amount of withdrawal: -2.45
       d -> Deposit Money
       w -> Withdraw Money
       r -> Request Balance
       q -> Quit
   Please select an option: r
   Beginning Balance: $2,019.45
   Withdrawal Amount: $(-2.45)
   Your balance is $2,021.90
       d -> Deposit Money
       w -> Withdraw Money
       r -> Request Balance
       q -> Quit
   Please select an option: q
   Thank you for banking with My Bank, test!

C++ only please, in this assignment you are to create an interactive line command driven C++ program that allows a user to do the following: 1) Create a bank ac
C++ only please, in this assignment you are to create an interactive line command driven C++ program that allows a user to do the following: 1) Create a bank ac
C++ only please, in this assignment you are to create an interactive line command driven C++ program that allows a user to do the following: 1) Create a bank ac
C++ only please, in this assignment you are to create an interactive line command driven C++ program that allows a user to do the following: 1) Create a bank ac
C++ only please, in this assignment you are to create an interactive line command driven C++ program that allows a user to do the following: 1) Create a bank ac
C++ only please, in this assignment you are to create an interactive line command driven C++ program that allows a user to do the following: 1) Create a bank ac
C++ only please, in this assignment you are to create an interactive line command driven C++ program that allows a user to do the following: 1) Create a bank ac
C++ only please, in this assignment you are to create an interactive line command driven C++ program that allows a user to do the following: 1) Create a bank ac
C++ only please, in this assignment you are to create an interactive line command driven C++ program that allows a user to do the following: 1) Create a bank ac

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site