atm bank machine

this is my header file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <iostream>
#include <string>
using namespace std;

class Account{
protected:
	string firstname;
	string lastname;
	int accountnumber;
	double balance;
public:
	Account();
	Account(string FName,string LName,int accno,double bal);
	void setAccountNumber(int accno);
	void setBalance(double bal);
	void setWithdraw(int wdraw,double bal);
	void setDeposit(int dep,double bal);
	double getBalance();
	string getFullName(string fName,string lName);
	void display(string FName,string LName);

};

Account::Account(){
	firstname="Raaj";
	lastname="Lokanathan";
	accountnumber=5671;
	balance=0.0;
}

Account::Account(string FName,string LName,int accno,double bal){
	firstname = FName;
	lastname = LName;
	accountnumber = accno;
	balance = bal;
}

void Account::setAccountNumber(int accno){
	accountnumber = accno;
}

void Account::setBalance(double bal){
	balance = bal;
}

void Account::setWithdraw(int wdraw,double bal){
	if(bal>=wdraw){
		wdraw=bal-wdraw;
		cout<<"Your current balance is: "<<wdraw<<endl;
	}else{
		cout<<"No money"<<endl;
	}
}

void Account::setDeposit(int dep,double bal){
	dep=dep+bal;
	cout<<"Your current balance is: "<<dep<<endl;
}

double Account::getBalance(){
	return balance;
}

string Account::getFullName(string FName,string LName){
	string FullName,x=" ";
	LName=x+LName;
	return FullName=FName+LName;
}

void Account::display(string FName,string LName){
	cout<<"First Name: "<<FName<<endl;
	cout<<"Last Name: "<<LName<<endl;
	cout<<"Full Name: "<<getFullName(FName,LName)<<endl;
	cout<<"Account Number: "<<accountnumber<<endl;
	cout<<"Current Balance: "<<balance<<endl;
}


this is my current account header file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef CURRENTACCOUNT_H
#define CURRENTACCOUNT_H
#include <iostream>
#include <string>
using namespace std;

class CurrentAccount:public Account{
	private:
		double overdraftlimit;
	public:
		CurrentAccount();
		CurrentAccount(string FName,string LName,int accno,double bal,double overd);
		void setOverdraftLimit(double overd);
		double getOverdraftLimit();
		void setwithdraw(double balance);
		void setdeposit(double dep);
		void display();
};

CurrentAccount::CurrentAccount():Account(){
	overdraftlimit=0.0;
}

CurrentAccount::CurrentAccount(string FName,string LName,int accno,double bal,double overd):Account(FName,LName,accno,bal){
	overdraftlimit=overd;
}

void CurrentAccount::setOverdraftLimit(double overd){
	overdraftlimit=overd;
}

double CurrentAccount::getOverdraftLimit(){
	return overdraftlimit;
}

void CurrentAccount::setwithdraw(double balance){
	int wdraw=0;
	wdraw=balance-wdraw;
	if(balance>=0){
		cout<<"Your Current Account Balance is "<<balance<<endl;
	}else if(balance<0){
		overdraftlimit=wdraw+overdraftlimit;
	}else{
		if(wdraw>=overdraftlimit){
		cout<<"Try again"<<endl;
		}else{
			cout<<"You passed your overdraftlimit"<<endl;
		}
	}
}

void CurrentAccount::setdeposit(double deposit){
	deposit=balance+deposit;
	cout<<"Your current balance is "<<deposit<<endl;
}



void CurrentAccount::display(){
	cout<<"Your overdraftlimit is: "<<overdraftlimit<<endl;
}

#endif 


this is my saving account header file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef SAVINGACCOUNT_H
#define SAVINGACCOUNT_H
#include <iostream>
#include <string>
using namespace std;

class SavingAccount:public Account{
	private:
		double save;
	public:
		SavingAccount():Account(){
			save=0.0;
		}
		SavingAccount(string FName,string LName,int accno,double bal);
		void setwithdraw(double bal);
		void setdeposit(double deposit);
		void display();
};

void SavingAccount::setwithdraw(double bal){
	int wDraw;
	wDraw=bal-wDraw;
	cout<<"Your Saving Account Balance is "<<wDraw<<endl;
}

void SavingAccount::setdeposit(double deposit){
	deposit=balance+deposit;
}

void SavingAccount::display(){
}

#endif 


my main source code...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef ACCOUNT_H
#define ACCOUNT_H
#include <iostream>
#include <string>
#include "Account.h"
#include "CurrentAccount.h"
#include "SavingAccount.h"
using namespace std;

int main(){ 
	Account Acc;
	CurrentAccount Curr;
	SavingAccount Sacc;
	Account acc[5];
	CurrentAccount curr[5];
	SavingAccount sacc[5];
	string first_name;
	string last_name;
	int acc_no,choice,Wdraw,Dep,chose;
	double bAl,Overd;
	int i=0;
	cout<<"-------------------------------"<<endl;
	cout<<"Welcome to Raaj Banking System"<<endl;
	cout<<"-------------------------------"<<endl;
	cout<<"Choose your account type below:"<<endl;
	cout<<"(1) Current Account"<<endl;
	cout<<"(2) Saving Account"<<endl;
	cout<<"(3) Print an Account"<<endl;
	cout<<"(4) Print all account"<<endl;
	cout<<"(5) EXIT"<<endl;
	cout<<"Choose wisely: ";
	cin>>chose;
	switch (chose){
	case 1:
		cout<<"Please enter the details for customer no "<<i+1<<endl;
		cout<<"Please enter your first name: ";
		cin>>first_name;
		cout<<"Please enter your last name: ";
		cin>>last_name;
		cout<<"Please enter your account number: ";
		cin>>acc_no;
		cout<<"Please enter your current balance: ";
		cin>>bAl;
		cout<<"Please enter your overdraftlimit: ";
		cin>>Overd;
		Curr.setOverdraftLimit(Overd);
		break;
	case 2:
		cout<<"Please enter your first name: ";
		cin>>first_name;
		cout<<"Please enter your last name: ";
		cin>>last_name;
		cout<<"Please enter your account number: ";
		cin>>acc_no;
		cout<<"Please enter your current balance: ";
		cin>>bAl;
		break;
	case 3:
		cout<<"Please enter your account number to be printed: ";
		cin>>acc_no;
		curr[i].display();
		sacc[i].display();
		break;
	case 4:
		curr[i].display();
		sacc[i].display();
		break;
	case 5:
		cout<<"EXIT"<<endl;
		break;
	}
	for(i=0;i<5;i++){
		cout<<"Please choose an option: "<<endl;
		cout<<"(1) Withdraw"<<endl;
		cout<<"(2) Deposit"<<endl;
		cout<<"(3) EXIT"<<endl;
		cout<<"-----------------------------------------------------"<<endl;
		cout<<"Please enter your choice: ";
		cin>>choice;
		switch(choice){
		case 1:
			cout<<"Please enter the amount you wish to withdraw: ";
			cin>>Wdraw;
			if(Wdraw>bAl)
				Curr.setwithdraw(bAl);
			else
				Sacc.setwithdraw(bAl);
		case 2:
			cout<<"Please enter the amount you wish to deposit: ";
			cin>>Dep;
			Acc.setDeposit(Dep,bAl);
			break;
		case 3:
			cout<<"Try again"<<endl; 
			break;
		} 
	}


	system("pause");

	return 0;

}
#endif


my program is getting the overdraftlimit and also the balance
Topic archived. No new replies allowed.