-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
90 lines (85 loc) · 3.37 KB
/
main.cpp
File metadata and controls
90 lines (85 loc) · 3.37 KB
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
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <vector>
#include <string>
using namespace std;
#include "Compte.h"
#include "CompteCheque.h"
#include "CompteEpargne.h"
int main() {
vector<Compte*> vect;
CompteCheque ct1(2500,5);
vect.push_back(&ct1);
CompteCheque ct2(1200,5);
vect.push_back(&ct2);
CompteEpargne ct3(3000,3.5);
vect.push_back(&ct3);
CompteEpargne ct4(500,3.5);
vect.push_back(&ct4);
cout<<"$$$$$$ Royal Bank is happy to treat you today $$$$$$"<<endl;
cout<<"we will go through all your accounts"<<endl;
string cpt;
for(int i=0;i<vect.size();i++){
if(i<2){
cout<<"******** YOUR CHEQUE ACCOUNT **********"<<endl;
cout<<"For a credit transaction enter 1 , for debit enter 2"<<endl;
cin>>cpt;
while(cpt!="1" && cpt!="2"){
cout<<"invalid choice please try again !"<<endl;
cout<<"For a credit transaction enter 1 , for debit enter 2"<<endl;
cin>>cpt;
}
double tmp;
if(cpt=="1"){
cout<<"Please enter the ammount you want to deposit : "<<endl;
cin>>tmp;
if(vect[i]->credit(tmp)){
cout<< "Deposit of "<<tmp <<" has been made succesfuly."<<endl;
cout<<"Your new balance is: "<<vect[i]->getBalance()<<endl;
}else{
cout<<"You've entered a negative number , transaction cancelled !"<<endl;
}
}else{
cout<<"Please enter the ammount you want to withdraw"<<endl;
cin>>tmp;
if(vect[i]->debit(tmp)){
cout<< "Withdraw of "<<tmp<<" has been succesful ."<<endl;
cout<<"your new balance is: "<<vect[i]->getBalance()<<endl;
}
}
}else{
cout<<"******** YOUR EPARGNE ACCOUNT **********"<<endl;
double itrs=vect[i]->calculateInterest();
cout<<"You've earned "<<itrs<<"$ as interest"<<endl;
vect[i]->credit(itrs);
cout<<"Your current balance is "<<vect[i]->getBalance()<<"$"<<endl;
cout<<"For a credit transaction enter 1 , for debit enter 2"<<endl;
cin>>cpt;
while(cpt!="1" && cpt!="2"){
cout<<"invalid choice please try again !"<<endl;
cout<<"For a credit transaction enter 1 , for debit enter 2"<<endl;
cin>>cpt;
}
double tmp;
if(cpt=="1"){
cout<<"Please enter the ammount you want to deposit : "<<endl;
cin>>tmp;
if(vect[i]->credit(tmp)){
cout<< "Deposit of "<<tmp <<" has been made succesfuly ."<<endl;
cout<<"Your new balance is: "<<vect[i]->getBalance()<<endl;
}else{
cout<<"You've entered a negative number , transaction cancelled !"<<endl;
}
}else{
cout<<"Please enter the ammount you want to withdraw"<<endl;
cin>>tmp;
if(vect[i]->debit(tmp)){
cout<< "Withdraw of "<<tmp<<" has been succesful ."<<endl;
cout<<"your new balance is: "<<vect[i]->getBalance()<<endl;
}
}
}
}
return 0;
}