Write a program that calculates 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 returned as an int. (The function accepts no arguments.)
• A function called by main that accepts one argument: the number of employees in the company. The function 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.
there is my code:
// Days Out is the programm that calculates the average number of days a company's
// employees are absent
#include <iostream>
using namespace std;
//Function prototypes
int numberEmployees();
int numberDays(int);
double averageDays(int, int);
int main()
{
//Declaring variables
int employees;
int total;
double average;
//Function call for first function
employees = numberEmployees();
//Function call for second function
total = numberDays(employees);
//Function call for last function prototype
average = averageDays(employees, total);
//Performing output by main function
cout<< "The average number of days a company's employees are absent is: " <<average<<endl;
return 0;
}
//Function header for number of employees
int numberEmployees()
{
int workers;
cout<<"Enter the number of employees in the company: ";
cin>>workers;
//Input validation
if(workers<=1)
{
cout<<" Do not accept number less than 1. Please, enter again: ";
cin>>workers;
}
return workers;
}
//Function header for the number of days
int numberDays(int w)
{
int workers = w;
int total = 0;
int absent;
//Creating a loop for every employees' missed days
for (int count=0; count<workers; count++)
{
cout <<"Enter the number of days each employee missed during past year: "<<count+1<<endl;
cin >>absent;
total+=absent;
//Input Validation
if (absent<0)
{
cout<<"Please, do not enter negative number! Try again: ";
cin>>absent;
}
}
return total;
}
//Function header for average number of days absent
double average (int work, int totl)
{
int w = work;
int t = totl;
double aver;
aver=(w*365)/t;
return aver;
}
thats the error:
error LNK2019: unresolved external symbol "double __cdecl averageDays(int,int)" (?averageDays@@YANHH@Z) referenced in function _main
1>c:\users\nastya\documents\visual studio 2010\Projects\DaysOut\Debug\DaysOut.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========