Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Assignment Description: In this assignment you will create a program that al

ID: 3690401 • Letter: C

Question

C++

Assignment Description:

In this assignment you will create a program that allows a user to choose one of the following main menu items:

C) Create new user account (Create an account with userId/password) L) Login
V) View promotions
Q) Quit the program

If User enters an option other than (uppercase or lowercase) C, L, V, or Q, the program does not do anything and shows a message wrong option and displays the menu again.

When user enters option C, the program asks the user to enter a userId and a password and successfully returns back to the main menu. The login and password should be stored in a file.

If the user chooses option L, the program will display the login prompt and then, it will ask for the password. At this stage, the entered login and password are compared to the stored login/password pair and proper message will show up if the match was not found which takes the user back to the main menu.

If the user chooses option V, the program will display the message: Thank you for using our bank and Future Computer Programmer ATM Machine! For your continued support, we are offering 3% cash back on all debit purchases.

Now, if login was successful, the following banking menu will be display to let the user choose one of the following tasks:

W) Withdraw money. D) Deposit money.
B) Request balance. Q) Quit the program.

(again, remember that if the user enters an option other than (uppercase or lowercase) W, D, B, Q, the program should show a message and display the menu again.)
The initial balance for the user account should be $0.00
If the user chooses option W, the program should ask the user to enter amount user wishes to withdraw.

Validation: In the case of withdraw, if the amount is more than balance the user should be notified and no withdraw will occur.

If the user chooses option D, the program should ask the user how much amount the user wishes to deposit and add it to initial balance.

If the user chooses option B, the program should display the balance amount in the user account.

Sample Output:
Hi! Welcome to Future Computer Programmer ATM Machine!

Please select an option from the menu below: l -> Login
c -> Create New Account
v -> View promotions

q -> Quit
Enter your choice: L
Please enter your user id: Please enter your password: No match was found! Login Failed!

Please select an option from the menu below: l -> Login
c -> Create New Account
v -> View promotions

q -> Quit

Enter your choice: c
Please enter your user name: Please enter your password: Thank You! Your account has been created!

Please select an option from the menu below: l -> Login
c -> Create New Account
v -> View promotions

q -> Quit
Enter your choice: l
Please enter your user id:
Please enter your password: Access Granted! Transferring to Account Menu!

Please select an option from the menu below d -> Deposit Money
w -> Withdraw Money
b -> Check Balance

r -> Review Account Activities History q -> Quit
Enter your choice: d
Enter amount of deposit: $

$20 was deposited.

Please select an option from the menu below d -> Deposit Money
w -> Withdraw Money
b -> Check Balance

r -> Review Account Activities History q -> Quit
Enter your choice: B
Your balance is $20.

Please select an option from the menu below d -> Deposit Money
w -> Withdraw Money
b -> Check Balance

r -> Review Account Activities History

q -> Quit
Enter your choice: W
Enter amount of withdrawal: $25
Sorry withdrawal amount exceeds the balance. Can’t withdraw !

Please select an option from the menu below d -> Deposit Money
w -> Withdraw Money
b -> Check Balance

r -> Review Account Activities History q -> Quit
Enter your choice: W
Enter amount of withdrawal: $ .

$2.5 was withdrawn

Please select an option from the menu below d -> Deposit Money
w -> Withdraw Money
b -> Check Balance

r -> Review Account Activities History q -> Quit
Enter your choice: b
Your balance is $17.5.

Please select an option from the menu below d -> Deposit Money
w -> Withdraw Money
b -> Check Balance

r -> Review Account Activities History q -> Quit
Enter your choice: R

Date and Time Sun Mar 20 12:48:18 2016 Sun Mar 20 12:52:41 2016 Sun Mar 20 12:54:31 2016 Sun Mar 20 12:55:57 2016 Sun Mar 20 12:57:08 2016

Transaction Amount Deposit $20 Check Balance $20

Status OK OK

Please select an option from the menu below d -> Deposit Money

Withdraw Req Withdraw Req Check Balance

$25
$2.5 OK

$17.5

Not OK OK

w -> Withdraw Money
b -> Check Balance
r -> Review Account Activities History q -> Quit
Enter your choice: Q

Log Out Successful!

Please select an option from the menu below: l -> Login
c -> Create New Account
v -> View promotions

q -> Quit
Enter your choice: Q

Thanks for stopping by!

Additional Instructions:
All transactions
should be stored in a file called transHistory.output as shown above for the Review Account Activities History.

NOTE: Do Not Use Excessive Global Variables. Using Global Variables in most functions may result in losing points for the designated function.

Choose the parameters and return types that you feel are right for the appropriate methods. Again, do not use an excessive amount of Global Variables, as you will lose points.

Please make sure your code has following functions:

1. char mainMenu(); //main menu, first thing the user sees. Displays the menu and gets the value for selection
2. void createAccount(); //will only display if the user has selected to create an account. Allows the user to enter his/her ID and password and then stores this login information in a file called accounts.txt
3. void login(); //this function gets the user name and password from the user. Must then match this account info, by comparing it to every item in the file accounts.txt, to indicate whether or not login was successful
4. char bankingMenu(): //will only display if the user has selected to log in.
5. void deposit (); //allows the user to put money into their accounts, prints success or fail upon deposit 6. void withdraw(); //allows the user to get money from their accounts, prints success or fail upon deposit
7. void displayBalance(); //shows the balance on the screen
8. void ShowTransHist(); //get the transaction history from the file path string and display

You can use additional functions (optional) for input validation and withdrawal amount validation. Your program should make use appropriate switch and if-else statements where necessary.

Explanation / Answer

#include <iostream>

#include <fstream>

#include <cstdlib>

#include <ctime>

using namespace std;

char mainMenu();//main menu, first thing the user sees.Displays the menu and gets the value for selection

void createAccount(); /*will only display if the user has selected to create an account. Allows the user to enter his/her ID and password and then stores this login information in a file called accounts.txt*/

char bankingMenu();//will only display if the user has selected to log in

class bank{ // Class is used in order to carry the variable bal through void functions

int bal; // Balance, running total used in functions

public :

void deposit(void); //allows the user to put money into their accounts, prints success or fail upon deposit

void withdraw(void); //allows the user to get money from their accounts, prints success or fail upon deposit

void login(void); /*this function gets the user name and password from the user. Must then match this account //info, by comparing it to every item in the file accounts.txt, to indicate whether or not login was successful*/

void displayBalance();//shows the balance on the screen

void ShowTransHist();}; //get the transaction history from the file path string and display

int main()

{

char choice;

bank account;

while (choice != 'q' || choice != 'Q')

{

choice = mainMenu();

if (choice == 'q' || choice == 'Q'){

cout << "Thanks for stopping by Justin's Bank!"; break;} /* I use break a lot in this program. Great for terminating/going back a menu*/

switch (choice)

{

case 'l':

case 'L':

account.login();

break;

case 'c':

case 'C':

createAccount();

break;

case 'v':

case 'V':

cout << "Thank you for using our bank and Future Computer Programmer ATM Machine! For your continued support, we are offering 3% cash back on all debit purchases." << endl;

default:

cout << "Invalid choice!" << endl;

}

}

return 0;

}

char mainMenu() //display main menu

{

char choice;

cout << "********** MAIN MENU ********** " << endl << endl;

cout << "l(L) -> Login to Banking Menu" << endl;

cout << "c -> Create New Account" << endl;

cout << "v -> View Promotions" << endl;

cout << "q -> Quit the Program" << endl;

cout << "Enter your choice:" << endl;

cin >> choice;

return choice;

}

void createAccount() //gets users login information, username/password

{

string username;

string password;

cout << "Please create a username" << endl;

cin >> username;

cout << "Please create a password" << endl;

cin >> password;

ofstream createaccount;

createaccount.open("accounts.txt"); // Will store the users information.

createaccount << username << endl;

createaccount << password;

createaccount.close();

cout << "Account created!" << endl;

}

void bank :: login(void) // gets information stored in create account.

{

string username;

string password;

char choice;

bank decision;

ifstream savedaccount;

savedaccount.open("accounts.txt"); // accounts.txt verify information of user.

cout << "Enter your username:" << endl;

cin >> username;

cout << "Enter your password:" << endl;

cin >> password;

string username2, password2;

savedaccount >> username2;

savedaccount >> password2;

if (username != username2 || password != password2)

cout << "Incorrect login! Create new account or try again." << endl;

while(username == username2 && password == password2) // Achieving by using accounts.txt match

{

choice = bankingMenu();// Place the function here so,it will only appear if user logins.

if (choice == 'q' || choice =='Q') break;

switch (choice){

case 'd':

case 'D':

decision.deposit();

break;

case 'w':

case 'W':

decision.withdraw();

break;

case 'b':

case 'B':

decision.displayBalance();

break;

case 'r':

case 'R':

decision.ShowTransHist();

break;

default:

cout << "Invalid choice!" << endl;

}

}

}

char bankingMenu() // Banking menu, only opens if user achieves login.

{

char choice;

cout << "********* BANKING MENU *********" << endl << endl;

cout << "d. Deposit Money" << endl;

cout << "w. Withdraw Money" << endl;

cout << "b. Check Balance" << endl;

cout << "r. Review Account Activities History" << endl;

cout << "q. Return to Main Menu" << endl;

cout << "Enter your choice:" << endl;

cin >> choice;

return choice;

}

void bank :: deposit(void) /* Takes balance variable from bank class and keeps it as a constant total, deposit adds to balance*/

{

long deposit;

cout << "Enter how much you would like to deposit: ";

cin >> deposit;

bal = deposit+bal;

cout << "You have deposited: $" << deposit << endl;

if (deposit >= 100000)

cout << "Now that is a lot of money!" << endl;

}

void bank :: withdraw(void) //subtracting from balance.

{

long withdraw;

cout << "Enter how much you would like to withdraw: ";

cin >> withdraw;

if (bal > withdraw || bal == withdraw){

bal= bal - withdraw;

cout << "You have withdrawn: $" << withdraw << endl;}

else if (bal < withdraw)

cout << "You don't have enough funds to cover your withdraw request!" << endl;

}

void bank :: displayBalance() /* Deposit and withdrawl are taken into account, and the constant total balance is displayed here.*/

{

cout << "Your current balance is: $" << bal << endl;

if (bal >= 1000000)

cout << "Wow, you're a high roller!" << endl;

}

void bank :: ShowTransHist()

{

ofstream balance;

int bal;

balance.open("transHistory.output", std::ios_base::app);

balance << bal << endl;

}