Answer to Question #273256 in C++ for Abdulqader

Question #273256

Write a program to create a class called employee, the class



has members , name , ID, and salary, a constructor to enter values



from users, and member function to display the result of the



following equation:



𝑀 =



𝑆𝑎𝑙𝑎𝑟𝑦



---------∗ 15



100

1
Expert's answer
2021-11-29T18:35:39-0500


SOLUTION CODE




#include <iostream>
using namespace std;


class employee
{
private:
	string name;
	string idNumber;
	int salary;
	


public:
	employee(string n, string idNum, int s)
	{
		name = n;
		idNumber = idNum;
		salary = s;
	}
	
    
    void display()
    {
    	cout<<"\nEmployee name: "<<name<<endl;
    	cout<<"Employee Id number: "<<idNumber<<endl;
    	cout<<"Employee Salary: "<<salary<<endl;
	}
};


int main()
{
		//Now propt the user for values
    	cout<<"\nEnter the employee name: ";
    	string employee_name;
    	cin>>employee_name;
    	cout<<"\nEnter the employee ID number: ";
    	string employee_id_number;
    	cin>>employee_id_number;
    	cout<<"\nEnter the employee salary: ";
    	int employee_salary;
    	cin>>employee_salary;
	employee my_0bject = employee(employee_name,employee_id_number, employee_salary);
	my_0bject.display();
	
}


SAMPLE PROGRAM OUTPUT






Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS