-
Average
Code:
Hello,
I have a question. i have to write a program that cvalculates the average number of days a company's employees are absent. The program should have the following functions:
A functcion called by main that asks teh user for the number of employees in the company. this value should be returned as an int. (no parameters)
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 employees in the company. The function should ask teh 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 parameters: 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 any screen output and does not ask the user for input.
Can anyone help i am getting many errors ...
the program i have so far is
#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;
int getnum_employees=0;
int total_days_missed=0;
double days_missed_average;
int main ()
{
cout<<"Please enter the number of employees"<<endl;
cin>>getnum_employees;
return getnum_employees;
}
int getdays_missed (getnum_employees)
{
while (num_employees>=1)
{
cout<<"Please enter days missed"<<endl;
cin>>getdays_missed;
total_days_missed += getdays_missed;
num_employees--;
}
return getdays_missed;
}
double getdays_missed_average(getnum_employees, getdays_missed)
{
days_missed_average = getdays_missed/num_employees;
cout<<"Average days missed: "<<days_missed_average;
system("pause");
return 0;
}
-
3 things comes to mind:
PLEASE don't put comments inside the code tags. Put them OUTSIDE. The code tags is for just that - code.
2) Indentation is messed up, needs work. Otherwise code is poorly readable.
3) Your understanding of the language is totally wrong. You need to re-read your books before attempting to create a project.
-
So what are you having trouble with?
And on a side note - dont use global variables. Keep them local in the created function and pass
them by value/reference when needed
-
Winterx - if you think reporting your own post to the moderators will get us to rush to your post and help you, then you are mistaken.
Reporting to the Mods is for issues that need dealing with immediately, not stupid stuff like this
THREAD CLOSED