Write the definition of a class STAFF in C++ with following description.

Private Members:
-SID //Staff ID of Long Integer
-Type //Type of Staff of Character type
-Pay           //Payment of Float type
-Name //Name of String type
-AssignPay()  //Pay as per Type assigned as per following:
Type Pay
D 95000
M 75000
E 60000
S 45000

Public members:
-Enroll()    //Function to allow user to enter values for
//SID, Type, Name & call AssignPay function.
-SeeData() //Function to display all the data members.

===============================================
Solution:
===============================================

class STAFF
{
long SID;
char Name[20];
char Type;
float Pay;
void AssignPay()
{
if(Type=='D') Pay=95000;
else if(Type=='M') Pay=75000;
else if(Type=='E') Pay=60000;
else if(Type=='S') Pay=45000;
}
void Enroll();
void SeeData();
};

void STAFF::Enroll()
{
cout<<"Enter Staff ID No.  : ";
cout<<"Enter Name          : ";
cout<<"Enter Type (D/M/E/S): ";
AssignPay();
}

void STAFF::SeeData()
{
cout<<"..........STAFF DATA..........\n";
cout<<"Staff ID   : "<<SID<<endl;
cout<<"Name       : "<<Name<<endl;
cout<<"Staff Type : "<<Type<<endl;
cout<<"Payment    : "<<Pay<<endl;
}



No comments

Post your comments

Powered by Blogger.