forked from thakursaurabh1998/cpp
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ques2.cpp
82 lines (76 loc) · 1.7 KB
/
ques2.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
// A bank maintains two accounts for customers i.e. Savings and Current.
// Savings account provides interest facility and current account provides check book facility.
// Create a class account that stores customer name, account number and type of account.
// It includes member functions that accept deposit and update balance.
// Display balance.
// Compute interest (Only in savings account).
// Permit withdrawl and update balance.
#include<iostream>
#include<string>
using namespace std;
class Account
{
public:
string name;
int type;
long accountNo;
float balance;
public:
Account(string n, int t, long ac, float b)
{
name = n;
type = t;
accountNo = ac;
balance = b;
}
void depositBalance(float d)
{
balance += d;
cout << "Balance updated after deposit" << endl;
}
void displayBalance()
{
cout << "Name: " << name << endl;
cout << "Account type: " << type << endl;
cout << "Account No: " << accountNo << endl;
cout << "Your current balance is: " << balance << endl;
}
void withdrawlBalance(float w)
{
balance -= w;
cout << "Balance updated after withdrawl" << endl;
}
~Account(){};
};
class Savings
{
float roi; //rate of interest
public:
Account ac;
Savings(float r,string n, long ac, float b, int t=1) : ac(n,t,ac,b)
{
roi = r;
}
void computeInterest()
{
cout << "Your interest calculated for one year is: " << ac.balance*roi/100 << endl;
}
~Savings(){};
};
class Current
{
public:
Account ac;
Current(string n, long ac, float b, int t=2) : ac(n,t,ac,b){};
~Current(){};
};
int main()
{
Current c("Ramesh",12345, 7659.54);
c.ac.displayBalance();
c.ac.withdrawlBalance(645);
c.ac.displayBalance();
c.ac.depositBalance(2700);
c.ac.displayBalance();
return 0;
}