Question
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
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.
I am having trouble with this problem following is my code but it never addes the absent days would you please help me with this. Thank you
/*
Name: Charles Dhital
Date:09/042017
Program: Chapter 6, Problem 13. Days out
Program: This program lets user to input number of employee in the company and then the days they have missed work. After user enters all the data it will display
the average days an employee has missed work
*/
#include
// the declaration of the basic standard input-output library in c++
#include
using namespace std; // all the element library are decleared within the namespace, namespace called std. in order to acess its functionality we declear with this expressiong
// that we will be using these entities
// Declear the function prototype
int numEmployee(); // this function will be called by the main and it will return int for number of employee in the company
int missedDays(int); // this function will be called by the main, which will be used to disply and calculate the number of days missed by the employee
double averageDaysMissed(int, int); // this function will accept the number of employee in the company and the total number of days missed by the employee and calculates the
// average.
int main() // this line corresponds to the beginning of the defination of the main function. The main function is the point where all c++ starts their execution
{
// Declear variables
int numberOfEmployee = 0; // this variable will be used to call the function numEmployee
int absentDays = 0; // this variable will be used to call the function missed days
double averageWorkMissed = 0.0; // this variablew will be used to call the function averageDaysMissed by the employee
double average = 0.0;
int total = 0;
// Calling the function numEmployee.
numberOfEmployee = numEmployee();
total = missedDays(numberOfEmployee);
cout <<" "<< numberOfEmployee << endl;
cout<<" "<< total << endl;
_getch();
return 0;
}
int numEmployee ()
{
// Declear the variable
int numberOfEmployee = 0; // this variable will hold the numbe of employee in the company
cout << " How many employee do you have in your compnay?:" << endl;
cin >> numberOfEmployee;
return numberOfEmployee;
}
int missedDays(int numberOfEmployee)
{
// Declear the variable
int missed = numberOfEmployee;
int absent = 0; // this variable will hold the number of days missed by the employee
int total = 0; // this variable will hold the total number of days missed by the number of employee in the company
for (int i = 1; i <= missed; i++)
{
cout << " How many days did employee " << i << " missed work during past year?:" << endl;
cin >>absent;
}
total+=absent;
return total;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started