hi im new to daniweb im currently working on a piece of work. the idea is to create a bank account with deposit and withdrawal functions. create student business and current accounts (this is all roughly done and a case of copying and pasting for each account type with a different set of questions) . what it requires me to do is allow 10 accounts to be opened and then allow the user to search for each one and deposit and withdraw from each one. would anyone have any suggestions on how i could do this. below is my code so far and thankyou for taking the time to look. also it requires me to take an object orientated approach and im rather confused what this entails, any suggestions again would be appreciated.
1st - BANK.CPP
#include <iostream>
#include <string>
using namespace std;
int main()
{
// Declare Variables
int withdraw;
int sqone;
int sqtwo;
int bone;
string colname;
string name;
string sname;
int housenumber;
string postcode;
string dob;
string telno;
double acctbalance, deposit;
char choices;
acctbalance = 0;
//inputs, get the name and initial balance
do
{
cout<<"\n\n-------------------------------------------------\n";
cout << "What do you wish to do?" << endl;
cout << "O open new account" << endl;
cout << "C open new Business account" << endl;
cout << "D Deposit Money" << endl;
cout << "W Withdraw Money" << endl;
cout << "B Display Balance" << endl;
cout << "P Bank Account Details" << endl;
cout << "Q Quit" << endl<<endl;cout<<"Enter selection: ";
cin >> choices;
switch (choices)
{
//add account type options here under letter O
case 'O':
case 'o':
{
{
cout<<"\n\n-------------------------------------------------\n";
cout << "What Account Do You Wish To Open?" << endl;
cout << "S Student Account" << endl;
cout << "C Current Account" << endl;
cout << "B Business Account" << endl;
cout<<"Enter selection: ";
cin >> choices;
break;// Need a break statement here
}
}
//STUDENT ACCOUNT
case 'S':
case 's':
{
cout<<"Please Answer The Following Questions / 1 = Yes, 2 = No "<<endl;
cout<<"---------------------------------------------------------"<<endl;
cout<<"Are You A Full Time Student?"<<endl;
cin>>sqone;
if (sqone == 0)
{
cout << "sorry that is not a valid option"<< endl;
break;
}
if (sqone == 2)
{
cout<<"Sorry You Are Not Valid For This Account"<<endl;
break;
}
else if (sqone == 1)
{
cout<<"Thankyou"<<endl;
cout<<"Have You Got Documentation To Support Your Course And Accomadation?"<<endl;
cin>>sqtwo;
if (sqtwo == 0)
{
cout << "sorry that is not a valid option"<< endl;
break;
}
if (sqtwo == 1)
{
cout<<"Thankyou you are elegible for this account"<<endl;
cout<<"------------------------------------------"<<endl;
cout << "Colleague Name: ";
cin >> colname;
cout << "Enter First Name: ";
cin >> name;
cout << "Enter Surname: ";
cin >> sname;
cout << "House Number: ";
cin >> housenumber;
cout << "Post Code: ";
cin >> postcode;
cout << "Date Of Birth: ";
cin >> dob;
cout << "Telephone Number: ";
cin >> telno;
cout << "Please enter initial balance: ";
cin >> acctbalance;
break;
}
else if (sqtwo == 2)
{
cout<<"Sorry You Are Not Valid For This Account"<<endl;
break;
}
//BUSINESS ACCOUNT
case 'c':
case 'C':
{
cout<<"Please Answer The Following Questions / 1 = Yes, 2 = No "<<endl;
cout<<"---------------------------------------------------------"<<endl;
cout<<"Have you got documentation showing your business details?"<<endl;
cin>>bone;
if (bone == 0)
{
cout << "sorry that is not a valid option"<< endl;
break;
}
if (bone == 2)
{
cout<<"Sorry You Are Not Valid For This Account"<<endl;
break;
}
if (bone == 1)
{
cout<<"We Will Now Proceed To Open This Account For You?"<<endl;
cout<<"------------------------------------------"<<endl;
cout << "Colleague Name: ";
cin >> colname;
cout << "Enter First Name: ";
cin >> name;
cout << "Enter Surname: ";
cin >> sname;
cout << "House Number: ";
cin >> housenumber;
cout << "Post Code: ";
cin >> postcode;
cout << "Date Of Birth: ";
cin >> dob;
cout << "Telephone Number: ";
cin >> telno;
cout << "Please enter initial balance: ";
cin >> acctbalance;
break;
}
else if (sqtwo == 2)
{
cout<<"Sorry You Are Not Valid For This Account"<<endl;
break;
}
}
}
}
case 'D':
case 'd':
{
cout << "Enter amount to be deposited: "<< endl;
cin >>deposit;
if (deposit > 0)
{
acctbalance = acctbalance + deposit;
if (deposit >= 10000)
cout <<"Big Money!"<<endl;
break;
}
if (deposit == 0 || deposit < 0)
{
cout <<"Amount must be greater than 0";
break ;
}
}
case 'B':
case 'b':
{
cout <<"Your current balance is $ "<<acctbalance<<'.'<<endl;
if (acctbalance ==0)
cout <<"Big Money!"<<endl;
break;
}
case 'W':
case 'w':
{
cout<<"Please enter amount to withdraw "<<endl;
cout<<"Withdrawal must be multiple of 10"<<endl;
cin>>withdraw;
if (withdraw == 00)
{
cout << "Can't withdraw 0 dollars"<< endl;
break;
}
if (withdraw < 0)
{
cout<<"Must be a positive number"<<endl;
break;
}
if (withdraw > acctbalance)
{
cout<<"Can't withdraw more than balance"<<endl;
break;
}
if ((withdraw % 10) !=0)
{
cout<<"amount must be a multiple of 20"<<endl;
break;
}
else
{
acctbalance=acctbalance - withdraw;
cout<<"Here is your money. Enjoy!"<< endl;
break;
}
case 'P':
case 'p':
{
cout << "\n\n"<<endl;
cout <<"Personal Details"<<endl;
cout <<"First Name : "<<name<<endl;
cout <<"Surname : " <<sname<<endl;
cout <<"house number : " <<housenumber<<endl;
cout <<"post code : " <<postcode<<endl;
cout <<"telephone number : " <<telno<<endl;
cout <<"Your current balance is £ "<<acctbalance<<'.'<<endl;
if (acctbalance ==0)
cout <<"Big Money!"<<endl;
break;
}
}
case 'Q':
case 'q':
{
cout<<"Thank for using our services have a nice day!"<<endl;
break;
}
}
}while (choices != 'q' && choices != 'Q');
return 0;
}
and the 2nd class - account.h
#include <iostream>
#include <string>
using namespace std;
class Account
{
double money; // amount of money held by this account
double interestRate; // a monthly or yearly interestrate, depending on how the account is to be used.
public:
// create an account with an initial amountand a specified interest rate
Account(double amount, double percent)
{
money = amount;
interestRate = percent;
}
// return the account's balance
double balance()
{
return money;
}
// add money to the account
void deposit(double amount)
{
money += amount;
}
// substract money from the account
void withdraw(double amount)
{
}
// add money according to the interest rate.
void addInterest()
{
money *= (1 + interestRate/100.0);
}
};
thankyou again