/******************* EDITOR VISUAL STUDIO CODE **********************/
J_3_P_11
/*******************************************************************************************
Define the following classes.
Class Data members Derived from
Account name, no, actype (C for current & none
S for saving
Current Chequeno, balance Account
Saving Balance Account
Also include appropriate constructors and other member functions for performing various
activities like to accept deposits of ten customers. To update balance of any customers and
to display the information of all the customers,
Write a C++ program, which implements these classes
*********************************************************************************************/
#include <iostream>
#include <conio.h>
using namespace std;
class account
{
public:
int accno;
char accname[20], actype[3];
public:
int getd()
{
cout << "\tEnter Account Name : ";
cin >> accname;
cout << "\tEnter Account Number :";
cin >> accno;
cout << "\tEnter Account Type (S or C) : ";
cin >> actype;
return 0;
}
int display()
{
cout << endl
<< "\tAccount name : " << accname;
cout << endl
<< "\tAccount Number : " << accno;
cout << endl
<< "\tAccount Type : " << actype << endl;
return 0;
}
};
class saving : public account
{
public:
long int balance;
public:
saving()
{
balance = 0;
}
int deposite()
{
cout << "\n\n----------------------------------------------------------------\n";
cout << "\t\tThis is Saving Account \n";
cout << "----------------------------------------------------------------\n\n";
getd();
display();
long int acno, amt;
cout << "\n\n----------------------------------------------------------------\n";
cout << "\t\t Deposite Amount in Saving Account \n";
cout << "----------------------------------------------------------------\n\n";
cout << "\tEnter Account Number :";
cin >> acno;
cout << "\tEnter Amount to Deposite s: ";
cin >> amt;
balance += amt;
return 0;
}
int withdraw()
{
int acno, amt;
cout << "\n\n----------------------------------------------------------------\n";
cout << "\t\t Withdraw Amount \n";
cout << "----------------------------------------------------------------\n\n";
cout << "\tEnter Account Number :";
cin >> acno;
cout << "\tEnter Amount to Withdraw : ";
cin >> amt;
balance -= amt;
return 0;
}
int displays()
{
cout << "\nBalance : " << balance << endl;
return 0;
}
};
class current : virtual public account
{
public:
long int balance;
public:
current()
{
balance = 0;
}
int deposite()
{
cout << "\n\n----------------------------------------------------------------\n";
cout << "\t\tThis is Current Account \n";
cout << "----------------------------------------------------------------\n\n";
getd();
display();
long int acno, amt;
cout << "\n\n----------------------------------------------------------------\n";
cout << "\t\t Deposite Amount in current Account \n";
cout << "----------------------------------------------------------------\n\n";
cout << "\tEnter Account Number :";
cin >> acno;
cout << "\tEnter Amount to Deposite : ";
cin >> amt;
balance += amt;
cout << "\n Balance : " << balance << endl;
return 0;
}
int getchk()
{
long int checkno, chamt;
cout << "\n\tEnter check Number : ";
cin >> checkno;
cout << "\tEnter Amount in check : ";
cin >> chamt;
balance -= chamt;
cout << "\n Balance : " << balance;
return 0;
}
};
int main()
{
system("cls");
int i;
current obj;
saving obj1;
obj1.deposite();
obj1.displays();
obj1.withdraw();
obj1.displays();
obj.deposite();
obj.getchk();
getch();
return 0;
}
Comments
Post a Comment