Skip to content

Instantly share code, notes, and snippets.

Created November 14, 2012 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4070228 to your computer and use it in GitHub Desktop.
Save anonymous/4070228 to your computer and use it in GitHub Desktop.
Average Number of Days Employees Take Off Calculator
#include <iomanip>
#include <iostream>
using namespace std;
int EMPPOP (void);
int EMPDAYS (int);
float AVGEMPDAYS (int, int);
int main (void) {
float EMTOTAL = EMPPOP ();
float EMTOTD = EMPDAYS (EMTOTAL);
//cout << EMTOTAL << " " << EMTOTD;
cout << "The average number of days missed per employee is " << AVGEMPDAYS (EMTOTD,EMTOTAL) << ".";
}
int EMPPOP () {
int EMTOTAL;
do {
cout << "How many employees does the company have? \n";
cin >> EMTOTAL;
if (EMTOTAL <= 0)
cout << "Number of employees must be one or greater.\n"; }
while (EMTOTAL <= 0);
return EMTOTAL;
}
int EMPDAYS (int x) {
int a, b = 0, EMDAYS;
for (int count = 1 ; count <= x ; count++)
{
do {
cout << "Days missed by Employee #" << count << "?\n";
cin >> EMDAYS;
if ( EMDAYS < 0 )
cout << "Days missed must be zero or greater.\n"; }
while (EMDAYS < 0);
a = EMDAYS + b;
b = a; }
return a;
}
float AVGEMPDAYS(int x, int y) {
float AVG = x / y;
return AVG ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment