Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Account {
- protected:
- string acc_title;
- string acc_no;
- double balance;
- public:
- void set_Values(string acc_title, string acc_no, double balance) {
- this->acc_title= acc_title;
- this->acc_no= acc_no;
- this->balance= balance;
- }
- void display() {
- cout << "\nTitle: " << acc_title << endl;
- cout << "Account Number: " << acc_no << endl;
- cout << "Balance: " << balance << endl;
- //cout << endl;
- }
- Account () {
- cout << "An account has been created." << endl;
- }
- Account (string acc_title, string acc_no, double balance) {
- this->acc_title= acc_title;
- this->acc_no= acc_no;
- this->balance= balance;
- }
- ~Account () {
- cout << "\nAn account has been deleted : " << acc_title << endl;
- }
- void diposit (double amount) {
- balance+=amount;
- cout << "Tk " << amount << " has been added to " << acc_title <<"'s account." << endl;
- }
- void withdraw (double amount) {
- if ((balance-amount)<=0)
- cout << "Withdraw cannot be possible due to low balance." << endl;
- else {
- balance-=amount;
- cout << "Tk " << amount << " has been withdrawn from " << acc_title <<"'s account." << endl;
- }
- }
- };
- class SV : public Account {
- double interest_rate;
- public:
- void set_interest(double interest) {
- interest_rate= interest;
- balance+=(balance*interest)/100; cout << endl;
- cout << interest_rate << "% interest has been added to the balance." << endl;
- //cout << balance << endl;
- }
- SV(string title, string no, double balance):Account(title,no,balance)
- {}
- void display() {
- cout << endl;
- Account::display();
- cout << "Interest Rate: " << interest_rate << endl;
- }
- };
- int main(void) {
- string name,num;
- double balance;
- cout << "Account Name: "; cin >> name;
- cout << "Account Number: "; cin >> num;
- cout << "Balance: "; cin >> balance;
- Account A1(name,num,balance);
- A1.display();
- cout << "\nAccount Name: "; cin >> name;
- cout << "Account Number: "; cin >> num;
- cout << "Balance: "; cin >> balance;
- SV S1(name,num,balance);
- S1.Account::display();
- S1.set_interest(10);
- S1.display();
- return 0;
- }
Add Comment
Please, Sign In to add comment