I have created the basic program for this assignment and inc
I have created the basic program for this assignment and included my code below. However, I\'m stuck on how to expanded per the instructions in bold.
C++ Programming Assignment
ATM Machine Phase 2
In this assignment you are to create an interactive line command driven C++ program that allows a user to do the following:
Create a bank account by supplying a user id and password
Login using this id and password
Quit the program
Upon successful login, the user will be presented with a menu to do one or more of the following actions:
Withdraw money
Deposit money
Request balance
Exit
During application initialization – create a new occurrence of a Banking Institution class, which contains the following for your institution
Institution ID : Your name
Course: “CIS2513”
Term: “Fall 2016”
Vector list of Bank Accounts [created during the online session]
When creating each Bank Account, you are to:
Ensure that your Bank Account does not already exist within the Banking Institution
Issue an error message if the bank account exists and DO NOT create a new Bank Account entry
Create the NEW Bank Account class occurrence if it does not exist
Add the NEW Bank Account to the Bank Institution Vector IN ASCENDING AlphaNumeric order by Bank Account User ID Value
For each NEW occurrence of the Bank Account classBank Account identification
User ID
Password
Creation Date and Time
Bank Account Balance
total value of all User ID account types as of last Balance Change Activity
Last Activity date and time
Three separate Account Type vectors for the supplied User ID
A Savings Account
A Line of Credit Account
A Checking Account
Each Account Type class occurrence (which must inherit these common characteristics) contains
Current Balance (which may be positive or negative)
A vector list of transactionsTransaction Type
Credit
Debit
Transaction Date and Time
Transaction Amount (Absolute value – these MUST all be positive Real values with FOUR decimal places)
For the Savings Account Type ONLY
Balance may NEVER be less than ZERO
Store the Date and Time of first Deposit
For the Checking Account ONLY
Balance may NEVER be less than ZERO
Store the Date and Time of most recent Deposit
Store the Date and Time of most recent Withdrawal
For the Line of Credit Account ONLY
Balance may NEVER be GREATER than ZERO
Store the Date and Time of first Withdrawal
Store the Amount of first Withdrawal
1) Withdraw money
For the amount of money requested by this User ID, create one (or more) debit transactions and record them as Transactions in the Vector List of the corresponding account type in the following sequence:
Up to the balance available in the Checking Account
Up to the balance available in the Savings Account
Up to the remaining amount requested by the User ID against the Line of Credit Account
2) Deposit money
For the amount of money deposited by this User ID, create one (or more) credit transactions and record them as Transactions in the Vector List of the corresponding account type in the following sequence:
Up to the outstanding balance (debt) in the Line of Credit Account (balance after deposit would be a maximum of zero)
Up to a maximum balance of $500 in the Checking Account
The remaining amount is to be deposited in the Savings Account
3) Request balance
a) Display the balance for all three account types
b) Display the TOTAL balance for the User ID (remember that the Line of Credit balance is ALWAYS negative or ZERO)
Your SAVINGS balance is : $ x,xxx.xx
Your CHECKING balance is : $ xxx.xx
Your LINE OF CREDIT balance is : $ x,xxx.xx
Your TOTAL balance is : $ x,xxx.xx
4) Exit the Bank Account Session
Return to the Main Menu for Create Account/Login/Quit
5) Quit the program
Output (to the Console) the following for each User ID
User ID
Last Activity date and Time
Total Balance
For each Account Type
Current Balance
Last Transaction Date and Time
For the Savings Account Type ONLY
Date and Time of first Deposit
For the Checking Account ONLY
Store the Date and Time of most recent Deposit
Store the Date and Time of most recent Withdrawal
For the Line of Credit Account ONLY
Store the Date and Time of first Withdrawal
Store the Amount of first Withdrawal
Exception to handle invalid input for one field without requiring re-entry of all values
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:
Visible when displayed on the screen (no control characters0
Normally accessible from a standard US keyboard
Separate your code into multiple functions and classes, 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.
Items in BOLD are user input:
Welcome to Chase\'s ATM Machine
Please select an option:
l -> Login
c -> Create New Account
q -> Quit
> l
Please enter your user id: Lucy
Please enter your password Ez3!%6&B
******** LOGIN FAILED! ********
Please select an option from the menu below:
l -> Login
c -> Create New Account
q -> Quit
> c
Please enter your user name: Robert!
Please enter your password: 7>#=S4zy
Thank You! Your account has been created!
l -> Login
c -> Create New Account
q -> Quit
> l
Please enter your user name: Robert!
Please enter your password: 7>#=S4zy
Access Granted - Robert!
d -> Deposit Money
w -> Withdraw Money
r -> Request Balance
x -> Exit
> d
Amount of deposit: $2056.45
d -> Deposit Money
w -> Withdraw Money
r -> Request Balance
x -> Exit
> r
Your SAVINGS balance is : $ 1,556.45
Your CHECKING balance is : $ 500.00
Your LINE OF CREDIT balance is : $ 0.00
Your TOTAL balance is : $ 2,056.45
d -> Deposit Money
w -> Withdraw Money
r -> Request Balance
x -> Exit
> d
Amount of deposit: 56.45
d -> Deposit Money
w -> Withdraw Money
r -> Request Balance
x -> Exit
> r
Your SAVINGS balance is : $ 1,612.90
Your CHECKING balance is : $ 500.00
Your LINE OF CREDIT balance is : $ 0.00
Your TOTAL balance is : $ 2,112.90
d -> Deposit Money
w -> Withdraw Money
r -> Request Balance
x -> Exit
> w
Amount of withdrawal: -2.5
d -> Deposit Money
w -> Withdraw Money
r -> Request Balance
x -> Exit
> r
Your SAVINGS balance is : $ 1,615.40
Your CHECKING balance is : $ 500.00
Your LINE OF CREDIT balance is : $ 0.00
Your TOTAL balance is : $ 2,115.40
d -> Deposit Money
w -> Withdraw Money
r -> Request Balance
x -> Exit
> w
Amount of withdrawal: 125.57
d -> Deposit Money
w -> Withdraw Money
r -> Request Balance
x -> Exit
> r
Your SAVINGS balance is : $ 1,615.40
Your CHECKING balance is : $ 374.43
Your LINE OF CREDIT balance is : $ 0.00
Your TOTAL balance is : $ 1,989.83
d -> Deposit Money
w -> Withdraw Money
r -> Request Balance
x -> Exit
> w
Amount of withdrawal: 6125.78
d -> Deposit Money
w -> Withdraw Money
r -> Request Balance
x -> Exit
> r
Your SAVINGS balance is : $ 0.00
Your CHECKING balance is : $ 0.00
Your LINE OF CREDIT balance is : -$ 4,135.95
Your TOTAL balance is : -$ 4,135.95
d -> Deposit Money
w -> Withdraw Money
r -> Request Balance
x -> Exit
> x
Thanks for banking with us, Robert!!
============================================
Welcome to Chase’s ATM Machine
Please select an option:
l -> Login
c -> Create New Account
q -> Quit
> c
… Create at least TWO additional Bank Account logins with at least three monetary transactions of various types
============================================
Welcome to Chase’s ATM Machine
Please select an option:
l -> Login
c -> Create New Account
q -> Quit
> q
List of all Account content for each User ID created in the session for the Banking Institution
#ifndef BANKACCOUNT_H
#define BANKACCOUNT_H
#include <iostream>
#include <string>
using namespace std;
class BankAccount {
public:
BankAccount(string userName, string userPassword);
string GetName();
string GetPassword();
void CreateAccount(string userName, string userPassword);
bool LoginInfo(string userName, string userPassword);
void DepositMoney(double &accountBalance, double depositAmount);
void WithdrawMoney(double &accountBalance, double withdrawalAmount);
private:
string userName;
string userPassword;
};
#endif
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <stdlib.h>
#include \"BankAccount.h\"
using namespace std;
BankAccount::BankAccount(string user_Name, string user_Password) {
userName = user_Name;
userPassword = user_Password;
return;
}
string BankAccount::GetName() {
return userName;
}
string BankAccount::GetPassword() {
return userPassword;
}
void CreateAccount(string userName, string userPassword){
ofstream account;
account.open(\"accounts.txt\");
account << userName << endl;
account << userPassword << endl;
account.close();
return;
}
bool LoginInfo(string userName, string userPassword){
ifstream login;
login.open(\"accounts.txt\");
string name;
string password;
if (login.is_open())
{
while (login >> name)
{
login >> password;
if (userName == name && userPassword == password){
return true;
}
}
}
login.close();
return false;
}
void Deposit(double accountBalance, double depositNum){
accountBalance += depositNum;
return;
}
void Withdraw(double accountBalance, double withdrawalNum){
if (accountBalance >= withdrawalNum)
{
accountBalance -= withdrawalNum;
}
else{
cout << \"Withdrawal amount exceeds account balance. Can\'t withdraw!\" << endl;
cout << endl;
}
return;
}
int main() {
string usrName;
string usrPassword;
char choice;
double accountBalance = 0.0;
double depositNum = 0.0;
double withdrawalNum = 0.0;
double initialBalance = 0.0;
char depositVal[50];
char withdrawalVal[50];
int length;
cout << \"Welcome to ATM Machine\" << endl;
cout << endl;
while (true){
cout << \"Please select an option:\" << endl;
cout << endl;
cout << \"l -> Login\" << endl;
cout << \"c -> Create New Account\" << endl;
cout << \"q -> Quit\" << endl;
cout << endl;
cin >> choice;
cout << endl;
switch (choice){
case \'l\':
case \'L\':
cout << \"Please enter your user id: \";
cin >> usrName;
cout << \"Please enter your password: \";
cin >> usrPassword;
if (LoginInfo(usrName, usrPassword)){
cout << endl;
cout << \"Access Granted - \" << usrName << endl;
cout << endl;
while (true)
{
cout << \"d -> Deposit Money\" << endl;
cout << \"w -> Withdraw Money\" << endl;
cout << \"r -> Request Balance\" << endl;
cout << \"q -> Quit\" << endl;
cout << endl;
cin >> choice;
cout << endl;
switch (choice){
case \'d\':
case \'D\':
cout << \"Amount of deposit: \";
cin >> depositVal;
length = strlen(depositVal);
if(depositVal[0] == \'$\')
{
for(int i = 0; i < length; i++) {
depositVal[i] = depositVal[i + 1];
}
}
depositNum = atof(depositVal);
initialBalance = accountBalance;
Deposit(accountBalance, depositNum);
break;
case \'w\':
case \'W\':
cout << \"Amount of withdrawal: \";
cin >> withdrawalVal;
length = strlen(withdrawalVal);
if(withdrawalVal[0] == \'$\')
{
for(int i = 0; i < length; i++) {
withdrawalVal[i] = withdrawalVal[i + 1];
}
}
withdrawalNum = atof(withdrawalVal);
initialBalance = accountBalance;
Withdraw(accountBalance, withdrawalNum);
break;
case \'r\':
case \'R\':
cout << \"Beginning balance: $\" << initialBalance << endl;
cout << \"Deposit amount: $\" << depositNum << endl;
cout << \"Withdrawal amount: $\" << withdrawalNum << endl;
cout << \"Your balance is: $\" << accountBalance << endl;
break;
case \'q\':
case \'Q\':
cout << \"Thanks for banking with us, \" << usrName << \"!\" << endl;
exit(1);
break;
default:
cout << \"Invalid option. Pick again.\" << endl;
break;
}
cout << endl;
}
}
else {
cout << endl;
cout << \"******** LOGIN FAILED! ********\" << endl;
}
break;
case \'c\':
case \'C\':
cout << \"Please enter your user name: \";
cin >> usrName;
cout << \"Please enter your password: \";
cin >> usrPassword;
CreateAccount(usrName, usrPassword);
cout << endl;
cout << \"Thank You! Your account has been created!\" << endl;
break;
case \'q\':
case \'Q\':
cout << \"Thanks for banking with us!\" << endl;
exit(1);
break;
default:
cout << \"Invalid option. Pick again.\" << endl;
}
cout << endl;
}
return 0;
}
| Welcome to Chase\'s ATM Machine Please select an option: l -> Login c -> Create New Account q -> Quit |
| > l Please enter your user id: Lucy Please enter your password Ez3!%6&B ******** LOGIN FAILED! ******** Please select an option from the menu below: l -> Login c -> Create New Account q -> Quit |
| > c Please enter your user name: Robert! Please enter your password: 7>#=S4zy Thank You! Your account has been created! l -> Login c -> Create New Account q -> Quit |
| > l Please enter your user name: Robert! Please enter your password: 7>#=S4zy Access Granted - Robert! d -> Deposit Money w -> Withdraw Money r -> Request Balance x -> Exit |
| > d Amount of deposit: $2056.45 d -> Deposit Money w -> Withdraw Money r -> Request Balance x -> Exit |
| > r Your SAVINGS balance is : $ 1,556.45 Your CHECKING balance is : $ 500.00 Your LINE OF CREDIT balance is : $ 0.00 Your TOTAL balance is : $ 2,056.45 d -> Deposit Money w -> Withdraw Money r -> Request Balance x -> Exit |
| > d Amount of deposit: 56.45 d -> Deposit Money w -> Withdraw Money r -> Request Balance x -> Exit |
| > r Your SAVINGS balance is : $ 1,612.90 Your CHECKING balance is : $ 500.00 Your LINE OF CREDIT balance is : $ 0.00 Your TOTAL balance is : $ 2,112.90 d -> Deposit Money w -> Withdraw Money r -> Request Balance x -> Exit |
| > w Amount of withdrawal: -2.5 d -> Deposit Money w -> Withdraw Money r -> Request Balance x -> Exit |
| > r Your SAVINGS balance is : $ 1,615.40 Your CHECKING balance is : $ 500.00 Your LINE OF CREDIT balance is : $ 0.00 Your TOTAL balance is : $ 2,115.40 d -> Deposit Money w -> Withdraw Money r -> Request Balance x -> Exit |
| > w Amount of withdrawal: 125.57 d -> Deposit Money w -> Withdraw Money r -> Request Balance x -> Exit |
| > r Your SAVINGS balance is : $ 1,615.40 Your CHECKING balance is : $ 374.43 Your LINE OF CREDIT balance is : $ 0.00 Your TOTAL balance is : $ 1,989.83 d -> Deposit Money w -> Withdraw Money r -> Request Balance x -> Exit |
| > w Amount of withdrawal: 6125.78 d -> Deposit Money w -> Withdraw Money r -> Request Balance x -> Exit |
| > r Your SAVINGS balance is : $ 0.00 Your CHECKING balance is : $ 0.00 Your LINE OF CREDIT balance is : -$ 4,135.95 Your TOTAL balance is : -$ 4,135.95 d -> Deposit Money w -> Withdraw Money r -> Request Balance x -> Exit |
| > x Thanks for banking with us, Robert!! ============================================ Welcome to Chase’s ATM Machine Please select an option: l -> Login c -> Create New Account q -> Quit |
| > c … Create at least TWO additional Bank Account logins with at least three monetary transactions of various types ============================================ Welcome to Chase’s ATM Machine Please select an option: l -> Login c -> Create New Account q -> Quit |
| > q List of all Account content for each User ID created in the session for the Banking Institution #ifndef BANKACCOUNT_H #include <iostream> class BankAccount { #endif #include <iostream> BankAccount::BankAccount(string user_Name, string user_Password) { string BankAccount::GetName() { string BankAccount::GetPassword() { void CreateAccount(string userName, string userPassword){ bool LoginInfo(string userName, string userPassword){ void Deposit(double accountBalance, double depositNum){ void Withdraw(double accountBalance, double withdrawalNum){ int main() { while (true){ |
Solution
/*
* C Program to Display the ATM Transaction
*/
#include <stdio.h>
unsigned long amount=1000, deposit, withdraw;
int choice, pin, k;
char transaction =\'y\';
void main()
{
while (pin != 1520)
{
printf(\"ENTER YOUR SECRET PIN NUMBER:\");
scanf(\"%d\", &pin);
if (pin != 1520)
printf(\"PLEASE ENTER VALID PASSWORD\ \");
}
do
{
printf(\"********Welcome to ATM Service**************\ \");
printf(\"1. Check Balance\ \");
printf(\"2. Withdraw Cash\ \");
printf(\"3. Deposit Cash\ \");
printf(\"4. Quit\ \");
printf(\"******************?**************************?*\ \ \");
printf(\"Enter your choice: \");
scanf(\"%d\", &choice);
switch (choice)
{
case 1:
printf(\"\ YOUR BALANCE IN Rs : %lu \", amount);
break;
case 2:
printf(\"\ ENTER THE AMOUNT TO WITHDRAW: \");
scanf(\"%lu\", &withdraw);
if (withdraw % 100 != 0)
{
printf(\"\ PLEASE ENTER THE AMOUNT IN MULTIPLES OF 100\");
}
else if (withdraw >(amount - 500))
{
printf(\"\ INSUFFICENT BALANCE\");
}
else
{
amount = amount - withdraw;
printf(\"\ \ PLEASE COLLECT CASH\");
printf(\"\ YOUR CURRENT BALANCE IS%lu\", amount);
}
break;
case 3:
printf(\"\ ENTER THE AMOUNT TO DEPOSIT\");
scanf(\"%lu\", &deposit);
amount = amount + deposit;
printf(\"YOUR BALANCE IS %lu\", amount);
break;
case 4:
printf(\"\ THANK U USING ATM\");
break;
default:
printf(\"\ INVALID CHOICE\");
}
printf(\"\ \ \ DO U WISH TO HAVE ANOTHER TRANSCATION?(y/n): \ \");
fflush(stdin);
scanf(\"%c\", &transaction);
if (transaction == \'n\'|| transaction == \'N\')
k = 1;
} while (!k);
printf(\"\ \ THANKS FOR USING OUT ATM SERVICE\");
}



















