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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
|
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <fstream>
#include <cstring>
#include <ctime>
using namespace std;
int main ()
{
cout<<"Welcome to Banca Muntenia";
e3:
cout<<"\n\n1.Create bank account\n2.Log into your bank account\n3.Exit"<<endl;
int dec,e;
string fname,sname,gen;
char sex;
e1:
cin>>dec;
if (dec==1)
{
cout<<"Enter your first name :";
cin>>fname;
cout<<"Enter your second name :";
cin>>sname;
e2:
cout<<"Enter your gender (M/F) :";
cin>>sex;
if (sex=='M'|| sex=='m')
{
gen="Mr.";
}
else if (sex=='F'|| sex=='f')
{
gen="Mrs.";
}
else
{
cout<<"Please enter a valid gender option !"<<endl;
goto e2;
}
int iban,iban1,iban2,iban3,iban4,iban5,iban6,iban7,iban8;
srand(time(NULL));
iban1=(rand()%10);
iban2=(rand()%10);
iban3=(rand()%10);
iban4=(rand()%10);
iban5=(rand()%10);
iban6=(rand()%10);
iban7=(rand()%10);
iban8=((rand()%9)+1);
iban=iban1*10000000+iban2*1000000+iban3*100000+iban4*10000+iban5*1000+iban6*100+iban7*10+iban8;
int pin1,pin2,pin3,pin4,pin;
pin1=(rand()%10);
pin2=(rand()%10);
pin3=(rand()%10);
pin4=((rand()%9)+1);
pin=pin1*1000+pin2*100+pin3*10+pin4;
ofstream ibantxt;
ofstream pintxt;
ofstream fnametxt;
ofstream snametxt;
ofstream gentxt;
ibantxt.open ("ibantxt.txt" , ios::app);
ibantxt << "ROBM" << iban << std :: endl ;
ibantxt.close();
pintxt.open ("pintxt.txt" , ios::app);
pintxt << pin << std :: endl ;
pintxt.close();
fnametxt.open ("fname.txt" , ios::app);
fnametxt << fname << std :: endl ;
fnametxt.close();
snametxt.open ("sname.txt", ios::app);
snametxt << sname << std :: endl ;
snametxt.close();
gentxt.open ("gender.txt", ios::app);
gentxt << gen << std :: endl ;
gentxt.close();
cout<<gen<<fname<<" "<<sname<<",your account has been created succesfully!\nYour IBAN is : ROBM"<<iban<<" and your PIN code is :"<<pin<<endl;
cout<<"You can use your IBAN and PIN to access your account at any time using an ATM"<<endl;
cout<<"Have a nice day !"<<endl;
goto e3;
}
else if (dec==2)
{
char readiban[40],readpin[40],readfname[40],readsname[40],readgender[40];
ifstream readibantxt;
ifstream readpintxt;
ifstream readfnametxt;
ifstream readsnametxt;
ifstream readgendertxt;
readibantxt.open ("ibantxt.txt");
readibantxt >> readiban;
readpintxt.open ("pintxt.txt");
readpintxt >> readpin;
readfnametxt.open ("fname.txt");
readfnametxt >> readfname;
readsnametxt.open ("sname.txt");
readsnametxt >> readsname;
readgendertxt.open ("gender.txt");
readgendertxt >> readgender;
char enteriban[30],enterpin[30];
e5:
cout<<"\nEnter your IBAN :";
cin>>enteriban;
if (strcmpi(enteriban,readiban)==0)
{
goto e4;
}
else
{
cout<<"This IBAN does not exist !"<<endl;
goto e5;
}
e4:
int j=0;
while (strcmpi(enterpin,readpin)!=0)
{
cout<<"\nEnter your PIN code : ";
cin>>enterpin;
j++;
if (strcmpi(enterpin,readpin)==0)
{
goto e6;
}
if (j==3)
{
cout<<"Too many failed attempts ! Account locked !"<<endl;
cin>>e;
return 0;
}
if (strcmpi(enterpin,readpin)!=0)
{
cout<<"Wrong PIN ! "<<3-j<<" attempts remaining !"<<endl;
}
}
e6:
cout<<"Welcome back , "<<readgender<<" "<<readfname<<" !"<<endl;
e7: int sum;
ifstream readsumtxt;
readsumtxt.open ("sum.txt");
readsumtxt >> sum;
cout<<"\nAccount ballance : $"<<sum<<endl;
cout<<"1.Add funds\n2.Withdraw\n3.Exit"<<endl;
int dec2;
cin>>dec2;
if (dec2==1)
{
int add;
e9:
cout<<"Introduce the sum you want to add into the ATM :";
cin>>add;
if (add<0)
{
cout<<"You can't add that sum !"<<endl;
goto e9;
}
sum=sum+add;
ofstream sumtxt;
sumtxt.open ("sum.txt");
sumtxt << sum;
sumtxt.close ();
goto e7;
}
else if (dec2==2)
{
int withdraw;
e8:
cout<<"Select the sum you would like to withdraw : ";
cin>>withdraw;
if (withdraw>sum)
{
cout<<"Insufficient funds !"<<endl;
goto e8;
}
if (withdraw<0)
{
cout<<"You can't withdraw that !"<<endl;
goto e8;
}
sum=sum-withdraw;
ofstream sumtxt;
sumtxt.open ("sum.txt");
sumtxt << sum;
sumtxt.close ();
goto e7;
}
else if (dec2==3)
{
return 0;
}
else
{
cout<<"Please choose a valid option !"<<endl;
goto e7;
}
}
else if (dec==3)
{
cout<<"Have a nice day !"<<endl;
cin>>e;
return 0;
}
else
{
cout<<"Please enter a valid choice !"<<endl;
goto e1;
}
}
|