Develop a C++ programs on BANKING SYSTEM have Customer class with name, address and phone no. Create derived class account class with data members like account number, name, deposit, withdraw amount and type of account. A customer can deposit and withdraw amount in his account. Develop a C++ program to display the details of a customer and the remaining balance amount. [Note: Use virtual function]
Sample Input :
41049
RAM
10000
2000
savings
output
41049
RAM
10000
2000
8000
#include <iostream>
#include <string>
using namespace std;
class Customer
{
public:
virtual void setData()
{
cout << "Enter customer name: ";
getline(cin, name);
cout << "Enter customer's address: ";
getline(std::cin, adress);
cout << "Enter customer's phone: ";
cin >> phone;
}
virtual void display()
{
cout << "Customer name: "<<name<<endl;
cout << "Customer's address: " << adress << endl;
cout << "Customer's phone: " << phone << endl;
}
protected:
string name;
string adress;
int phone;
};
class Client :public Customer
{
public:
void setData() override
{
cout << "Enter customer account_number: ";
cin >> account_number;
cin.ignore();
Customer::setData();
cout << "Enter customer deposit: ";
cin >> deposit;
cout << "Enter customer winthdraw: ";
cin >> winthdraw;
cout << "Enter customer account type: ";
cin >> type_account;
}
void display()override
{
cout << "Customer account_number: " << account_number << endl;
Customer::display();
cout << "Customer deposit: " << deposit << endl;
cout << "Customer winthdraw: " << winthdraw << endl;
cout << "Customer account type: " << type_account << endl;
cout << "Overall balance: " << deposit - winthdraw << endl;
}
void makeDeposit(double money)
{
deposit += money;
}
void withdrawMoney(double money)
{
winthdraw += money;
}
private:
int account_number;
double deposit;
double winthdraw;
string type_account;
};
int main()
{
Client test;
double money;
test.setData();
cout << endl;
cout << "Enter the amount of the deposit: ";
cin >> money;
test.makeDeposit(money);
cout << "Enter the amount to withdraw money: ";
cin >> money;
test.withdrawMoney(money);
cout << endl;
test.display();
return 0;
}
Comments
Leave a comment