// pgm21 Days Out Program // this is example 13 on pg 370 in textbook // 10/19/2016 #include #include using namespace std; // prototypes int getNumEmp(); int getDaysOut(int); double average(double, double); int main() { // get number of employees in the company int n, sumDays; n = getNumEmp(); cout << "number of employees is: " << n << endl; // read in number of days out for n employees sumDays = getDaysOut(n); cout << "sum of days out is: " << sumDays << endl; // calculate the average number of days out cout << "average number of days out is: "; double avg = average(sumDays, n); cout << avg << endl; return 0; } int getNumEmp() { // reads in the number of employees and returns it int numemp; cout << "How many employees do you have? "; cin >> numemp; // input validation: do not accept a number < 1 while (numemp<1) { cout << "Enter a valid number: "; cin >> numemp; } return numemp; } int getDaysOut(int num) { // read in days out for each employee and sum them // return the sum int days, sum=0; for (int i=0; i> days; if (days<0) days=0; sum+=days; } return sum; } double average(double sum, double emps) { // calculate the average number of days out and return it return sum/emps; } /* LAB: Write a function to test whether a value is divisible by some number that the user inputs. in main: user enters 2 numbers: x and y Check whether x is divible by y by calling your function. main will print whether x is divisibly by y or not. */