toezaurus81
06-23-04, 08:49 PM
/*Define a class Citizen with three attributes: Name (type sting), Id (type string),
and race (type string). Provide two member functions to input and output the three data.
Implement a class Customer with the following attributes: Account Number (type int),
Account type (type string) and Balance (type double). Provide member functions to accept
and display the data. Your Customer class should inherit the Citizen class.
Implement a class Employee with the following attributes: Organization (type string),
Basic Salary (type double), allowance percent (type double), deduction percent (type double).
Provide member functions to accept and display the data.
*/
#include<iostream>
#include<string>
using namespace std;
class Citizen
{
protected:
char Name[50];
char Id[20];
char Race[30];
public:
void input()
{
cout<<"\nEnter Citizen's information"<<endl;
cout<<"***************************"<<endl;
cout<<"Enter Name: ";
cin.getline(Name,50);
cout<<"Enter Id: ";
cin.getline(Id,20);
cout<<"Enter Race: ";
cin.getline(Race,30);
}
void output()
{ cout<<"\nCitizen's information"<<endl;
cout<<"*********************"<<endl;
cout<<"Name: "<<Name<<endl;
cout<<"Id: "<<Id<<endl;
cout<<"Race: "<<Race<<endl;
}
};
class Customer:Citizen
{
private:
int Account_Number;
char Account_Type[30];
double Balance;
public:
void accept()
{
cout<<"\nEnter Customer's information"<<endl;
cout<<"****************************"<<endl;
cout<<"Enter Account Number: ";
cin>>Account_Number;
cout<<"Enter Account Type: ";
cin.getline(Account_Type,30); //can't accept user input
cout<<"Enter Balance: ";
cin>>Balance;
}
void display()
{ cout<<"\nCustomer's information"<<endl;
cout<<"*********************"<<endl;
cout<<"Account Number: "<<Account_Number<<endl;
cout<<"Account Type: "<<Account_Type<<endl;
cout<<"Balance: "<<Balance<<endl;
}
};
class Employee
{
private:
char Organization[30];
double Basic_Salary;
double Allowance_percent;
double Deduction_percent;
public:
void accept()
{
cout<<"\nEnter Employee's information"<<endl;
cout<<"****************************"<<endl;
cout<<"Enter Organization: ";
cin.getline(Organization,30); //can't accept user input
cout<<"Enter Basic Salary: ";
cin>>Basic_Salary;
cout<<"Enter Allowance Percent: ";
cin>>Allowance_percent;
cout<<"Enter Deduction Percent: ";
cin>>Deduction_percent;
}
void display()
{
cout<<"\nEmployee's information"<<endl;
cout<<"*********************"<<endl;
cout<<"Organization: "<<Organization<<endl;
cout<<"Basic Salary: "<<Basic_Salary<<endl;
cout<<"Allowance Percent: "<<Allowance_percent<<endl;
cout<<"Deduction Percent: "<<Deduction_percent<<endl;
}
};
void main()
{
Citizen cit;
Customer cust;
Employee emp;
cit.input();
cit.output();
cout<<endl;
cust.accept();
cust.display();
emp.accept();
emp.display();
}
and race (type string). Provide two member functions to input and output the three data.
Implement a class Customer with the following attributes: Account Number (type int),
Account type (type string) and Balance (type double). Provide member functions to accept
and display the data. Your Customer class should inherit the Citizen class.
Implement a class Employee with the following attributes: Organization (type string),
Basic Salary (type double), allowance percent (type double), deduction percent (type double).
Provide member functions to accept and display the data.
*/
#include<iostream>
#include<string>
using namespace std;
class Citizen
{
protected:
char Name[50];
char Id[20];
char Race[30];
public:
void input()
{
cout<<"\nEnter Citizen's information"<<endl;
cout<<"***************************"<<endl;
cout<<"Enter Name: ";
cin.getline(Name,50);
cout<<"Enter Id: ";
cin.getline(Id,20);
cout<<"Enter Race: ";
cin.getline(Race,30);
}
void output()
{ cout<<"\nCitizen's information"<<endl;
cout<<"*********************"<<endl;
cout<<"Name: "<<Name<<endl;
cout<<"Id: "<<Id<<endl;
cout<<"Race: "<<Race<<endl;
}
};
class Customer:Citizen
{
private:
int Account_Number;
char Account_Type[30];
double Balance;
public:
void accept()
{
cout<<"\nEnter Customer's information"<<endl;
cout<<"****************************"<<endl;
cout<<"Enter Account Number: ";
cin>>Account_Number;
cout<<"Enter Account Type: ";
cin.getline(Account_Type,30); //can't accept user input
cout<<"Enter Balance: ";
cin>>Balance;
}
void display()
{ cout<<"\nCustomer's information"<<endl;
cout<<"*********************"<<endl;
cout<<"Account Number: "<<Account_Number<<endl;
cout<<"Account Type: "<<Account_Type<<endl;
cout<<"Balance: "<<Balance<<endl;
}
};
class Employee
{
private:
char Organization[30];
double Basic_Salary;
double Allowance_percent;
double Deduction_percent;
public:
void accept()
{
cout<<"\nEnter Employee's information"<<endl;
cout<<"****************************"<<endl;
cout<<"Enter Organization: ";
cin.getline(Organization,30); //can't accept user input
cout<<"Enter Basic Salary: ";
cin>>Basic_Salary;
cout<<"Enter Allowance Percent: ";
cin>>Allowance_percent;
cout<<"Enter Deduction Percent: ";
cin>>Deduction_percent;
}
void display()
{
cout<<"\nEmployee's information"<<endl;
cout<<"*********************"<<endl;
cout<<"Organization: "<<Organization<<endl;
cout<<"Basic Salary: "<<Basic_Salary<<endl;
cout<<"Allowance Percent: "<<Allowance_percent<<endl;
cout<<"Deduction Percent: "<<Deduction_percent<<endl;
}
};
void main()
{
Citizen cit;
Customer cust;
Employee emp;
cit.input();
cit.output();
cout<<endl;
cust.accept();
cust.display();
emp.accept();
emp.display();
}