Question
I need a Pseudocode and flowchart #include #include #include #include using namespace std; int getNumberOfEmployees(); int writeFile(ofstream &myFile, int n); double averageDaysAbsent(int n, int totalDays);
I need a Pseudocode and flowchart
#include
#include
#include
#include
using namespace std;
int getNumberOfEmployees();
int writeFile(ofstream &myFile, int n);
double averageDaysAbsent(int n, int totalDays);
int main()
{
int NumEmployees, totalDays;
double avg;
string name;
cout << "Calculate the average number of days a company's employees are absent. ";
NumEmployees = getNumberOfEmployees();
ofstream myfile;
myfile.open("employeeAbsences.txt");
totalDays = writeFile(myfile, NumEmployees);
avg = averageDaysAbsent(NumEmployees, totalDays);
cout << "Programmer: ";
cin >> name;
myfile << "The average number of days absent is " << avg << " days. ";
myfile << "Programmer: " << name;
myfile.close();
system("pause");
return 0;
}
int getNumberOfEmployees()
{
int NumEmployees;
cout << "Please enter the number of employees in the company: ";
cin >> NumEmployees;
while (NumEmployees < 1)
{
cout << "Number of employees cannot be less than 1." << endl;
cout << "Please re-enter the number of employeess in the company: ";
cin >> NumEmployees;
}
return NumEmployees;
}
int writeFile(ofstream &myfile, int NumEmployees)
{
int totalDays = 0;
int empid, daysAbsent;
myfile << "EMPLOYEE ABSENCE REPORT ";
myfile << "employee id\t\tdays absent ";
for (int i = 0; i < NumEmployees; i++)
{
cout << "Please enter an employee ID: ";
cin >> empid;
cout << "Please enter the number of days this employee was absent: ";
cin >> daysAbsent;
while (daysAbsent<0)
{
cout << "The number of days must not be negative." << endl;
cout << "Please re-enter the number of days absent: ";
cin >> daysAbsent;
}
myfile << setw(8) << empid << "\t\t\t" << setw(3) << daysAbsent << " ";
totalDays = totalDays + daysAbsent;
}
myfile << " The " << NumEmployees << " employees were absent a total of " << totalDays << " days. ";
return totalDays;
}
double averageDaysAbsent(int NumEmployees, int totalDays)
{
return (double)(totalDays) / (double)(NumEmployees);
}
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