Answer to Question #186030 in C++ for python

Question #186030

Create a structure called employee that contains two members: an employee

number (type int) and the employee’s compensation (in dollars; type float). Ask the

user to fill in this data for three employees, store it in three variables of type struct

employee, and then display the information for each employee.


1
Expert's answer
2021-04-27T00:02:45-0400
#include <iostream>
#include <iomanip>
using namespace std;


//Create a structure called employee that contains two members: an employee
//number (type int) and the employee’s compensation (in dollars; type float). 
struct Employee{
	 int number;
	 float compensation;
};


int main(){  
	struct Employee employee[3];
	//Ask the user to fill in this data for three employees store it in three variables of type struct employee
	for(int i=0;i<3;i++){
		cout<<"Enter the employee number "<<(i+1)<<": ";
		cin>>employee[i].number;
		cout<<"Enter the employee compensation "<<(i+1)<<": ";
		cin>>employee[i].compensation;
		cout<<"\n";
	}
	//display the information for each employee.
	cout<<"\n";
	for(int i=0;i<3;i++){
		cout<<"The employee number "<<(i+1)<<": "<<employee[i].number<<"\n";
		cout<<"The employee compensation "<<(i+1)<<": "<<employee[i].compensation<<"\n";
	}


	system("pause");
	return 0;
}

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

Umaima shafiq
16.06.22, 15:47

Excellent

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS