-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic-bank-account-management-without-inheritance.cpp
92 lines (88 loc) · 1.99 KB
/
basic-bank-account-management-without-inheritance.cpp
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
// Including Header File
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <process.h>
// Using Namespace std
using namespace std;
// Bank class declaration
class Bank_Account
{
// Declaration of data members
public:
char name[20];
char account_type[20];
int account_number;
int balance;
// member functions of the class Bank
// initialize function to initialize data members
void initialize()
{
cout << "\nEnter Account Holders Name:";
gets(name);
cout << "\nEnter Account type:";
gets(account_type);
cout << "\nEnter account number:";
cin >> account_number;
cout << "\Enter balance to deposit:";
cin >> balance;
}
// deposit() function to deposit amount in account
void deposit()
{
int bal;
cout << "\nEnter the amout to deposit:";
cin >> bal;
balance += bal;
cout << "\nAmount deposited successfully\nYour New Balance:" << balance;
}
// check() function to withdraw amount and check remaining balance
void check()
{
int bal;
cout << "\nYour balance :" << balance << "\nEnter amount to withdraw:";
cin >> bal;
if (bal <= balance)
{
balance -= bal;
cout << "\nRemaining Balance:" << balance;
}
else
{
exit(0);
}
}
// display function to display user information
void display()
{
cout << "\nName :";
puts(name);
cout << "\nBalance :" << balance;
}
};
int main()
{
int i;
// clrscr();
// An array of objects of Bank class can be created to handle 10 customers and their data
// as Bank bk[10];
// Then run this array in loop to initialize and access it's data members
Bank_Account bk;
bk.initialize();
cout << "\n 1. Your Information\n 2. Deposit\n 3. Withdraw\n Enter your choice\n";
cin >> i;
if (i == 1)
{
bk.display();
}
else if (i == 2)
{
bk.deposit();
}
else if (i == 3)
{
bk.check();
}
getch();
return 0;
}