Quick C++ Function Help

Hey everyone,

I have done all of the assignment so far except for one part. Here is the assignment:

Write a program that calculates the average number of days a company's employees are absent. The program should have the following functions:

(1) A function that asks the user for the number of employees in the company. (no parameters, returns an int).

Example:
"How many employees does your company have?" 3

(2) A function that asks the user to enter the number of days each employee missed during the past year. (1 parameter for number of employees, returns total of days missed for all employees)

Example:
"How many days did Employee #1 miss?" 3
"How many days did Employee #2 miss?" -1
"The number of days absent must be >= 0."
"How many days did Employee #2 miss?" 6
"How many days did Employee #3 miss?" 0

(3) A function to calculate the average number of days absent (2 int parameters: number of employees and number of days, returns float storing average number of days missed.)

Example:
"The average number of days absent is: 3"

Your program should not accept negative numbers as input: use loops to ensure this.

To get full credit you must follow the instructions on how each function should be organized.

I have completed everything except the part where it says that the average number returns float storing average number of days missed. Does this mean that if the average is a decimal the program should output it as a decimal as well and not have it truncate? If so, the problem I'm having seems to only include the whole integer number and no decimals. Here is my code:

 ``` #include "stdafx.h" #include using namespace std; int EmployeeNumber(); int DaysMissed(int); float AverageDays(int,int); int main() { int EmployeeNum; int AbsentDays; float average; EmployeeNum = EmployeeNumber(); AbsentDays = DaysMissed(EmployeeNum); average = AverageDays(EmployeeNum, AbsentDays); cout << "The average number of days absent is: " << average << endl; system("pause"); return 0; } int EmployeeNumber() { int employeeNum; cout << "How many employees does your company have? "; cin >> employeeNum; while(employeeNum < 1) { cout << "Please enter a value that is greater than 0. " << endl; cin >> employeeNum; } return employeeNum; } int DaysMissed(int employeeNum) { int totalDays = 0; int employee; for(int counter = 1; counter <= employeeNum; counter++) { cout << "How many days did employee #" << counter << " miss? "; cin >> employee; if(employee < 0) { cout << "Please enter a non-negative number for the days missed. " << endl; cout << "How many days did employee #" << counter << " miss? "; cin >> employee; } totalDays += employee; } return totalDays; } float AverageDays(int employeeNum, int totalDays) { float averageDays; averageDays = (totalDays / employeeNum); return averageDays; } ```

What am I doing wrong here? I've spent a couple hours figuring this out haha. Thank you so much for any help. =)
Replied to you in other topic.
Please do not cross-post one topic in several forums.
Topic archived. No new replies allowed.