Answer to Question #256692 in C++ for Dion Martins

Question #256692

Write a C++ program that will read in, for 20 employees, their employee number and the number of days absent for the year. You must then determine and display the following:


1. The employee numbers of all the employees who were not absent at all during the year.

2. The average number of days of absence for the year, and

3. The employee number of the person with the most days absent.


1
Expert's answer
2021-11-01T01:58:46-0400
#include<iostream>
#include<iomanip>
using namespace std;
int ENum();
int DNum(int);
double Average(int, int);
int main()
{
	int ENum_info = 0;
	int EId_info = 0; 
	int DNum_info = 0;
	double AAve_info = 0.0;
	ENum_info = ENum();
	DNum_info = DNum(ENum_info);
	AAve_info = Average(ENum_info, DNum_info);
	cout << "The average employee absent days last year: " << endl << AAve_info;
	cout << endl;
	system("pause");
	return 0;
}
int ENum()
{
	int ENum_1;


	cout << "Enter number of employees: ";
	cin >> ENum_1;


	while (ENum_1 < 1)
	{
		cout << "The number of employee must be greater than 0.";
		cout << "Please re-enter the number of employee.";
		cin >> ENum_1;
	}
	return ENum_1;
}


int DNum(int e)
{
	int ENum_1 = e;
	int DNum_1;
	int total_days = 0;


	for (int i = 0; i < ENum_1; i++)
	{
		int EId;


		cout << "Please enter employee ID: ";
		cin >> EId;
		cout << "Enter number of Days " << EId << "  missed last year: ";
		cin >> DNum_1;
		total_days += DNum_1;


		if (DNum_1 < 0)
		{
			cout << "The number of days must not be negative." << endl;
			cout << "Please re-enter the number of days absent: ";
			cin >> DNum_1;
		}
		if(DNum_1==0){
			cout<<"\nEmployees with no absent days\n "<<EId<<" ";
		}
	}
	return total_days;
}
double Average(int a, int b)
{
	int ENum_1 = a;
	int total_days = b;
	double AAve_1;


	AAve_1 = total_days /ENum_1;
	return AAve_1;


}

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