Created
November 14, 2012 04:18
-
-
Save anonymous/4070228 to your computer and use it in GitHub Desktop.
Average Number of Days Employees Take Off Calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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