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 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
|
#include <iostream>
#include <ctime>
#include <string>
#include <fstream>
using namespace std;
class info{
protected:
string first_name , middle_name , last_name , cnic , address , phone , Date;
info *next;
public:
info()
{
first_name = "NULL"; middle_name = "NULL"; last_name = "NULL";
cnic = "NULL"; address = "NULL"; phone = "NULL" ; Date = "NULL" ; next = NULL;
}
void Set_data()
{
cout<<"Enter First Name "; cin>>first_name;
cout<<"Enter Middle Name "; cin>>middle_name;
cout<<"Enter Last Name "; cin>>last_name;
cout<<"Enter CNIC Number "; cin>>cnic;
cout<<"Enter ADDRESS "; cin>>address;
cout<<"Enter Phone Number "; cin>>phone;
cout<<"Enter Date in this Format dd/mm/yy "; cin>>Date;
cout<<"\n\n";
}
void show_data()
{
cout<<
"First Name is "<< first_name <<
"\nMiddle Name is "<<middle_name <<
"\nLast Name is "<<last_name<<
"\nCNIC is "<<cnic<<
"\nADDRESS is "<<address<<
"\nPhone Number is "<<phone<<
"\nDate of Birth is"<<Date<<"\n\n";
}
void Link_List( info **ph , info **pt , info *pd )
{
if(*ph == NULL && *pt== NULL)
{
*ph = pd;
*pt = pd;
}
else
{
(*pt)->next=pd;
*pt = pd;
}
}
void display_data(info *p)
{
while(p != NULL)
{
cout<<
"First Name is "<< p->first_name <<
"\nMiddle Name is "<<p->middle_name <<
"\nLast Name is "<<p->last_name<<
"\nCNIC is "<<p->cnic<<
"\nADDRESS is "<<p->address<<
"\nPhone Number is "<<p->phone<<
"\nDate of Birth is"<<p->Date<<"\n\n";
p=p->next;
}
}
};
// ********************* ACCOUNT CLASSESS ***********************
class account{
public:
account(){
i = 0;
balance = 0;
transaction_during_one_day = 0;
one_month_balance = 0;
minimumBalance = 99999999999999;
startTime = clock();
}
void depositBalance(){
cout<<"\nEnter Amount: "; double u; cin>>u;
balance = u;
//Setting minimum Balance.
double currentTime = clock();
double timeElapsed = currentTime - startTime;
double seconds = (double) timeElapsed/CLOCKS_PER_SEC;
if (minimumBalance > balance){
minimumBalance = balance;
}
if (seconds >= 2.62974*1000000){
one_month_balance = minimumBalance;
startTime = 0;
}
}
void withDraw(){
bool fine = 0;
if (i == 0){ //first time.
sTime = clock();//Time starts when First Transaction is done.
}
i = 1;
do{
cout << "Enter Amount to withdraw: "; double amount; cin >> amount;
cTime = clock();
double diffT = cTime - sTime;
double seconds = (double) diffT/CLOCKS_PER_SEC;
if(seconds <= 86400){ //During 1 day
transaction_during_one_day += amount;
}
if (seconds >86400){
sTime = clock();
}
if (amount > balance){
cout << "You do not have sufficient amount of Money in your account." << endl;
fine = 1;
}
else{
if (amount>=5000)
{
amount -= (amount * 0.002); // 0.2% "service charges" Deducted during transaction over 5000.
}
balance -= amount;
fine = 0;
if (transaction_during_one_day > 50000){
balance -= 2.5*0.01*transaction_during_one_day;
}
}
}while (fine == true);
}
double getBalance(){
return balance;
}
void displayBalance(){
cout << "Balance: " << balance << endl;
}
protected:
bool i;
double minimumBalance;
double transaction_during_one_day;
double balance;
double startTime;
double sTime;//startTime;
double cTime;//currentTime
double one_month_balance;
};
class checking_account : virtual public account
{
};
class savingAccount: virtual public account{
public:
savingAccount(){
minimumBalance = balance;
}
void setInterest(){
// double endTime = clock();
// double timeElapsed = endTime - startTime;
// double time_elapsed_in_seconds = (double)timeElapsed/CLOCKS_PER_SEC; //convert to seconds
// if (time_elapsed_in_seconds > 30){
interest = one_month_balance * 0.01;
balance += interest;
cout << "Balance: " << balance << endl;
// }
}
double getInterest(){
return interest;
}
protected:
double interest;
};
class credit_card{
protected:
const unsigned int card_number;
static int counter;
public:
credit_card() : card_number(counter) { counter++; }
//void get_card() { cin >> card_number; }
void show_card_num() const { cout << card_number; }
};
class master : public credit_card , account
{
public:
void master_interest()
{
balance = balance + ( balance * 0.18 );
}
void upper_limit ( unsigned int &amount)
{
if (amount > 0 && amount > 50000)
cout<<"You cannot withdraw amount above Fifty Thousand\n\n ";
else
balance = balance - amount;
}
};
class visa : public credit_card , account
{
public:
void visa_interest()
{
balance = balance + ( balance * 0.1 );
}
void upper_limit(unsigned int &amount)
{
if ( amount > 0 && amount > 100000)
cout<<"\nYou cannot withdraw amount above One Lac\n\n ";
else
{
balance = balance - amount;
cout<<" Congratulation!\nYou have earned "<< amount << "frequent usage points\n";
}
}
};
class local : public credit_card , account
{
protected:
static int counter_local;
unsigned long double checking_amount;
public:
local()
{
checking_amount = balance;
}
void local_interest()
{
//if ( counter_local < 4 )
balance = balance + ( balance * 0.25 );
}
void decrease_local_interest()
{
balance = balance + ( checking_amount * 0.2 );
}
void upper_limit(unsigned int &amount)
{
if ( counter_local < 3 && amount < checking_amount )
{
if ( amount > 10000)
cout<<"\nYou cannot withdraw amount above Ten Thousand.\n\n ";
else
if ( amount < balance )
{
balance = balance - amount;
counter_local++;
}
}
else
{
if ( amount > 15000)
cout<<"\nYou cannot withdraw amount above Fifteen Thousand.\n\n ";
else
if ( amount < balance )
{
balance = balance - amount;
}
}
}
};
class user : public info , local , visa , master , savingAccount , checking_account
{
};
static int counter=1;
static int counter_local=1;
int main()
{
user obj;
obj.Set_data();
cout<<"Which type of account you want to open? "; char opt; cin >> opt;
switch(opt)
{
case 's':
case 'S':
obj.account::depositBalance();//WE WANT TO ACCESS member fuction depositBalance() of Class account.
break;
case 'c':
case 'C':
break;
default:
cout<<"\nyou selected Wrong option\n\n ";
}
return 0;
}
|