Posted by: nepali8 May 2, 2011
IT -- Solutions Center[Forum]
Login in to Rate this Post:     0       ?        
 program that calculates and displays the average number of days a company’s employees are absent. The program should have the following functions:

· A function called by main that asks the user for the number of employees in the company. This value should be entered (and returned) as an int. It has no arguments.

· A function called by main that accepts one argument, the number of employees in the company. It should ask the user to enter the number of days each employee missed during the past year. The total of these days should be returned as an int.

· A function called by main that takes two arguments, the number of employees in the company and the total number of days absent for all employees during the year. The function should return as a double, the average number of days absent. (This function does not perform screen output and does not ask the user for input).

Input validation: Do not accept a number less than 1 for the number of employees. Do not accept a negative number for the days any employee missed.

so far,
#include <iostream>
#include <iomanip>
using namespace std;
 
 
void Employee();
void Absents();
double AvgAbsents(int, int);
int main()
{
int nEmployees = 0;
int nTotalAbsents = 0;
double dAvgAbsents = 0.0;
 
nEmployees = Employee();
nTotalAbsents = Absents();
 
dAvgAbsents = AvgAbsents(nEmployees, nTotalAbsents );
 
cout << "The average days missed is " << dAvgAbsents <<endl;
return 0;
}
 
int getEmployees()
{
int n = 0;
cout <<"Enter the Number of Employees: ";
cin >> n, &n;
return n;
}
 
int getAbsents(int nEmployees)
{
int sum =0;
int n = 0;
int i;
for (i = 0; i < nEmployees; i ++)
{
cout <<"Enter the days ansent: ";
cin >>n , &n;
sum += n;
}
return sum;
}
 
double getAvgAbsents(int nEmployees, int nAbsences)
{
double avg =0.0;
if(nEmployees>0)
avg = (double)nAbsences/(double)nEmployees;
return avg ;
}
 
error i got.
 
6 10\6 10\6.cpp(15) : error C2440: '=' : cannot convert from 'void' to 'int'
6 10\6 10\6.cpp(16) : error C2440: '=' : cannot convert from 'void' to 'int'
 
Thanks in advance
Read Full Discussion Thread for this article