Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- using namespace std;
- int employeeAmount, employeeAmountCounter;
- int employeeNumber, daysAbsent;
- int totalDaysAbsent, averageDaysAbsent;
- //double totalDaysAbsent2, averageDaysAbsent2;
- ofstream outputFile;
- void numberOfEmployees()
- {
- cout << "How many employees are in the company? ";
- }
- int employeeInformation(int &employeeNumber, int &daysAbsent, int &employeeAmountCounter, int totalDaysAbsent)
- {
- for (employeeAmountCounter = 0; employeeAmountCounter < employeeAmount; employeeAmountCounter++)
- {
- cout << "What is the employee's number?" << endl;
- cin >> employeeNumber;
- cout << "How many days was this employee absent?" << endl;
- cin >> daysAbsent;
- totalDaysAbsent += daysAbsent;
- employeeAmountCounter++;
- outputFile << employeeNumber << "\t\t" << daysAbsent;
- }
- return(totalDaysAbsent);
- }
- double averageDaysAbsentFunction(int totalDaysAbsent, int employeeAmount, double averageDaysAbsent)
- {
- averageDaysAbsent = totalDaysAbsent / employeeAmount;
- return (averageDaysAbsent);
- }
- int main()
- {
- cout << "This program will calculate the average number of days each employee is absent." << endl;
- numberOfEmployees();
- cin >> employeeAmount;
- while (employeeAmount < 1)
- {
- cout << "\nInvalid entry. Please enter a new amount for the number of employees" << endl;
- cout << "that is greater than or equal to 1." << endl;
- cin >> employeeAmount;
- }
- outputFile.open("employeeAbsences.txt");
- outputFile << "EMPLOYEE ABSENCES REPORT\n";
- employeeInformation(employeeNumber, daysAbsent, employeeAmount, employeeAmountCounter);
- averageDaysAbsentFunction(totalDaysAbsent, employeeAmount, averageDaysAbsent);
- outputFile << "-------------------------------------------------------------------------------------";
- outputFile << employeeAmount << " employees were absent for a total of ";
- outputFile << totalDaysAbsent << " days.\n";
- outputFile << "The average number of days absent is ";
- outputFile << setprecision(1) << showpoint << fixed << averageDaysAbsent << " days.\n";
- outputFile << "Programmer:\t Amanda Yoresh";
- outputFile << "-------------------------------------------------------------------------------------";
- outputFile.close();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement