Program should be in C Create an employee class in which the

Program should be in C++

Create an employee class in which the member data should comprise an int for storing the employee number and a float for storing the employee\'s compensation. Member functions should allow the user to enter this data and display it. Write a main() that allows the user to enter data for three employees and display it.

Solution

#include<iostream.h>

class Employee

{

//Member variables

private:

int empNo;

float compensation;

//Member Functions

public:

void Input();

void Display();

};

void Employee ::Input()

{

cout<<\"Enter employee number:\";

cin>>empNo;

cout<<\"Enter employee\'s compensation:\";

cin>>compensation;

}

void Employee :: Display()

{

cout<<\"Employee Details:\";

cout<<\"\ Employee No:\"<<empNo;

cout<<\"\ Employee compensation:\"<<compensation;

}

void main()

{

//Create the object of class Employee to access the member function and varibale to fill the details.

Employee objEmp;

objEmp.Input(); //enter the details

objEmp.Display(); //Prints Employee details.

}

Program should be in C++ Create an employee class in which the member data should comprise an int for storing the employee number and a float for storing the em
Program should be in C++ Create an employee class in which the member data should comprise an int for storing the employee number and a float for storing the em

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site