#include <iostream>
#include <string>
#include "bankAccount.h"
bankAccount createAccount();
void MakeTransaction(bankAccount);
void AccountSummary(bankAccount);
using namespace std;
int main(){
int choice;
bankAccount User;
//count=0;
do{
//Bank Menu
cout<< " Bank Account Menu\n\n";
cout<< "1.Create a new Account\n";
cout<< "2.Make transaction\n";
cout<< "3.Account Summary\n";
cout<< "4.Quit Program\n\n";
cout<< "Enter your choice: ";
cin>>choice;
switch (choice)
{
case 1: User=createAccount();
break;
case 2: MakeTransaction(User);
break;
case 3: AccountSummary(User);
break;
//case 4: exit(1);
//break;
}
}while(choice!=4);
return 0;
}
bankAccount createAccount(){
string name,address,dob,phonenum;
int input,amount;
cout<<"What is the name of the new customer?"<<endl;
cin.ignore();
getline(cin,name);
cout<<"What is the address of the new customer?"<<endl;
//cin>>address;
getline(cin,address);
cout<<"What is the customers date of birth?"<<endl;
//cin>>dob;
getline(cin,dob);
cout<<"What is the customers phone number?"<<endl;
//cin>>phonenum;
getline(cin,phonenum);
bankAccount user(name,address,dob,phonenum);
cout<<"Which kind of account does the customer want to create(type in 1-3)?"<<endl;
cout<< "1.Checking\n";
cout<< "2.Savings\n";
cout<< "3.CD";
cin>>input;
switch(input){
case 1: cout<<"How much money would you like to deposit in order to create account?";
cin>>amount;
user.setBalance("checkings",amount);
break;
case 2:cout<<"How much money would you like to deposit in order to create account?";
cin>>amount;
user.setBalance("savings",amount);
break;
case 3: cout<<"How much money would you like to deposit in order to create account?";
cin>>amount;
user.setBalance("CD",amount);
break;
}
return user;
}
void MakeTransaction(bankAccount user){
string account,transaction;
double amount;
cout<<"Which account would you like to make a transaction in (checkings,savings or CD)?";
cin>>account;
cout<<"What transaction would you like to make (deposit or withdrawal)?";
cin>>transaction;
cout<<"For how much money would the transaction be?";
cin>>amount;
if (account=="checkings")
user.editCheckings(transaction,amount);
if (account=="savings")
user.editSavings(transaction,amount);
if (account=="CD")
user.editCD(transaction,amount);
}
void AccountSummary(bankAccount user){
user.accountSummary();
}
#ifndef BANKACCOUNT_H
#define BANKACCOUNT_H
#include <string>
using namespace std;
class bankAccount{
private:
string name;
string address;
string birthdate;
string phone_number;
double checkingsBAL;
double savingsBAL;
double cdBAL;
public:
bankAccount(){checkingsBAL=-1.0;savingsBAL=-1.0;cdBAL=-1.0;}
bankAccount(string,string,string,string);
void setBalance (string,double);
void editCheckings(string,double);
void editSavings(string,double);
void editCD(string,double);
double getBalance(string);
void accountSummary();
};
bankAccount::bankAccount(string NAME, string ADDRESS,string DOB,string PHONE_NUMBER){
name=NAME;
address=ADDRESS;
birthdate=DOB;
phone_number=PHONE_NUMBER;
checkingsBAL=-1.0;
savingsBAL=-1.0;
cdBAL=-1.0;
}
void bankAccount::setBalance(string accounttype, double accountBAL){
if (accounttype=="checkings")
checkingsBAL=accountBAL;
if (accounttype=="savings")
savingsBAL=accountBAL;
if (accounttype=="CD")
cdBAL=accountBAL;
}
void bankAccount:: editCheckings(string transaction,double transAmount){
if (transaction=="deposit")
checkingsBAL=checkingsBAL+transAmount;
if (transaction=="withdraw")
checkingsBAL=checkingsBAL+transAmount;
}
void bankAccount:: editSavings(string transaction,double transAmount){
if (transaction=="deposit")
savingsBAL=(savingsBAL+transAmount)*1.05;
if (transaction=="withdraw")
savingsBAL=savingsBAL+transAmount;
}
void bankAccount:: editCD(string transaction,double transAmount){
if (transaction=="deposit")
cdBAL=(cdBAL+transAmount)*1.1;
if (transaction=="withdraw")
cdBAL=cdBAL+transAmount;
}
double bankAccount:: getBalance(string accounttype){
if (accounttype=="checkings")
return checkingsBAL;
if (accounttype=="savings")
return savingsBAL;
if (accounttype=="CD")
return cdBAL;
}
void bankAccount::accountSummary(){
cout<<"Here is the Account Summary"<<endl;
cout<<"NAME: "<<name<<endl;
cout<<"ADDRESS: "<<address<<endl;
cout<<"BIRTHDATE: "<<birthdate<<endl;
cout<<"PHONE NUMBER: "<<phone_number<<endl;
if (checkingsBAL>=0)
cout<<"Checking Account Balance: "<<checkingsBAL<<endl;
else
cout<<"There is no checking account for this person"<<endl;
if (savingsBAL>=0)
cout<<"Savings Account Balance: "<<savingsBAL<<endl;
else
cout<<"There is no checking account for this person"<<endl;
if (cdBAL>=0)
cout<<"CD Account Balance: "<<cdBAL<<endl;
else
cout<<"There is no CD account for this person"<<endl;
}
# endif

New Topic/Question
Reply



MultiQuote




|