So Ive started most of it but I get confused with how to sto
So I\'ve started most of it but, I get confused with how to store the time and how to make the vector for the bank accounts. Also, my checking isn\'t working properly either and I\'m not sure why. Any modifications to the original code and help with the additional code would be greatly appreciated.
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 (ref: step one from Project 1), 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
This is my code:
#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;
double CHECKING;
double SAVINGS;
double creditLine;
double balanceTotal;
Howard_COP2513_F1601()
{
userInput = \' \';
userInput2 = \' \';
id = \"?\";
password = \"?\";
ID = \"?\";
PASSWORD = \"?\";
DEPOSIT = 0.00;
WITHDRAW = 0.00;
OLDBALANCE = 0.00;
NEWBALANCE = 0.00;
CHECKING = 0.00;
SAVINGS = 0.00;
creditLine = 0.00;
balanceTotal = 0.00;
}
void bankOption()
{
cout << \"Please select an option: \" << endl;
cout << \"l -> Login \" << endl;
cout << \"c -> Create New Account \" << endl;
cout << \"q -> Quit \" << endl;
cout << \"x -> Exit \" << endl;
cin >> userInput;
if (userInput == \'l\' || userInput == \'L\')
{
login();
}
else if (userInput == \'c\' || userInput == \'C\')
{
createAcnt();
}
else if (userInput == \'q\' || userInput == \'Q\')
{
quit();
}
else if (userInput == \'x\' || userInput == \'X\') {
exit();
}
}
void moneyOption()
{
cout << \"d -> Deposit Money \" << endl;
cout << \"w -> Withdraw Money \" << endl;
cout << \"r -> Request Balance\" << endl;
cout << \"q -> Quit \" << endl;
cout << \"x -> Exit \" << 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();
}
else if (userInput2 == \'x\' || userInput2 == \'X\') {
exit();
}
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 << endl;
cout << \"Access Granted - \" << ID << endl;
moneyOption();
}
else
{
cout << endl;
cout << \"******** \" << \"LOGIN FAILED! \" << \"********\" << endl << 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;
cout << endl;
cout << \"Thank You! Your account has been created!\" << endl << endl;
bankOption();
return 0;
}
int quit()
{
cout << \"Thanks for banking with COP2513.F16,\" << ID << \"!\" << endl;
system(\"pause\");
return 0;
}
int exit()
{
cout << \"Thanks for banking with COP2513.F16,\" << ID << \"!\" << endl << endl;
bankOption();
return 0;
}
int dMoney()
{
cout << \"Amount of deposit: \" << endl;
cin >> DEPOSIT;
OLDBALANCE = NEWBALANCE;
NEWBALANCE = OLDBALANCE + DEPOSIT;
if (creditLine < 0) {
creditLine = creditLine + NEWBALANCE;
}
else if (NEWBALANCE > 500 || CHECKING == 500) {
CHECKING = 500;
SAVINGS = NEWBALANCE - CHECKING;
}
else {
CHECKING = NEWBALANCE;
}
balanceTotal = SAVINGS + CHECKING;
moneyOption();
return 0;
}
int wMoney()
{
cout << \"Amount of withdrawal: \" << endl;
cin >> WITHDRAW;
OLDBALANCE = NEWBALANCE;
NEWBALANCE = OLDBALANCE - WITHDRAW;
if (NEWBALANCE < 0) {
creditLine = abs(NEWBALANCE);
}
else {
creditLine = 0.00;
CHECKING = NEWBALANCE;
}
balanceTotal = SAVINGS + CHECKING;
moneyOption();
return 0;
}
int rBalance()
{
cout << \"Your SAVINGS balance is: \" << \"$ \" << fixed << setprecision(2) << SAVINGS << endl;
cout << \"Your CHECKING balance is: \" << \"$ \" << fixed << setprecision(2) << CHECKING << endl;
cout << \"Your LINE OF CREDIT balance is: \" << \"$ \" << fixed << setprecision(2) << creditLine << endl;
cout << \"Your TOTAL balance is: \" << \"$ \" << fixed << setprecision(2) << balanceTotal << endl;
cout << endl;
moneyOption();
return 0;
}
};
int main()
{
Howard_COP2513_F1601 obj1;
obj1.bankOption();
return 0;
}
I also need to include headers which I though I\'ve already did but, I guess i didn\'t put enough of them. Thanks again for the help.
Solution
Every thing is fine. just add header file #include<cmath> for abs function used.
#include <iostream>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cmath>
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;
double CHECKING;
double SAVINGS;
double creditLine;
double balanceTotal;
Howard_COP2513_F1601()
{
userInput = \' \';
userInput2 = \' \';
id = \"?\";
password = \"?\";
ID = \"?\";
PASSWORD = \"?\";
DEPOSIT = 0.00;
WITHDRAW = 0.00;
OLDBALANCE = 0.00;
NEWBALANCE = 0.00;
CHECKING = 0.00;
SAVINGS = 0.00;
creditLine = 0.00;
balanceTotal = 0.00;
}
void bankOption()
{
cout << \"Please select an option: \" << endl;
cout << \"l -> Login \" << endl;
cout << \"c -> Create New Account \" << endl;
cout << \"q -> Quit \" << endl;
cout << \"x -> Exit \" << endl;
cin >> userInput;
if (userInput == \'l\' || userInput == \'L\')
{
login();
}
else if (userInput == \'c\' || userInput == \'C\')
{
createAcnt();
}
else if (userInput == \'q\' || userInput == \'Q\')
{
quit();
}
else if (userInput == \'x\' || userInput == \'X\') {
exit();
}
}
void moneyOption()
{
cout << \"d -> Deposit Money \" << endl;
cout << \"w -> Withdraw Money \" << endl;
cout << \"r -> Request Balance\" << endl;
cout << \"q -> Quit \" << endl;
cout << \"x -> Exit \" << 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();
}
else if (userInput2 == \'x\' || userInput2 == \'X\') {
exit();
}
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 << endl;
cout << \"Access Granted - \" << ID << endl;
moneyOption();
}
else
{
cout << endl;
cout << \"******** \" << \"LOGIN FAILED! \" << \"********\" << endl << 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;
cout << endl;
cout << \"Thank You! Your account has been created!\" << endl << endl;
bankOption();
return 0;
}
int quit()
{
cout << \"Thanks for banking with COP2513.F16,\" << ID << \"!\" << endl;
system(\"pause\");
return 0;
}
int exit()
{
cout << \"Thanks for banking with COP2513.F16,\" << ID << \"!\" << endl << endl;
bankOption();
return 0;
}
int dMoney()
{
cout << \"Amount of deposit: \" << endl;
cin >> DEPOSIT;
OLDBALANCE = NEWBALANCE;
NEWBALANCE = OLDBALANCE + DEPOSIT;
if (creditLine < 0) {
creditLine = creditLine + NEWBALANCE;
}
else if (NEWBALANCE > 500 || CHECKING == 500) {
CHECKING = 500;
SAVINGS = NEWBALANCE - CHECKING;
}
else {
CHECKING = NEWBALANCE;
}
balanceTotal = SAVINGS + CHECKING;
moneyOption();
return 0;
}
int wMoney()
{
cout << \"Amount of withdrawal: \" << endl;
cin >> WITHDRAW;
OLDBALANCE = NEWBALANCE;
NEWBALANCE = OLDBALANCE - WITHDRAW;
if (NEWBALANCE < 0) {
creditLine = abs(NEWBALANCE);
}
else {
creditLine = 0.00;
CHECKING = NEWBALANCE;
}
balanceTotal = SAVINGS + CHECKING;
moneyOption();
return 0;
}
int rBalance()
{
cout << \"Your SAVINGS balance is: \" << \"$ \" << fixed << setprecision(2) << SAVINGS << endl;
cout << \"Your CHECKING balance is: \" << \"$ \" << fixed << setprecision(2) << CHECKING << endl;
cout << \"Your LINE OF CREDIT balance is: \" << \"$ \" << fixed << setprecision(2) << creditLine << endl;
cout << \"Your TOTAL balance is: \" << \"$ \" << fixed << setprecision(2) << balanceTotal << endl;
cout << endl;
moneyOption();
return 0;
}
};
int main()
{
Howard_COP2513_F1601 obj1;
obj1.bankOption();
return 0;
}












