c++     plz include explanation in // format . thnx

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter5: Looping
Section: Chapter Questions
Problem 15E
icon
Related questions
Question

c++   

 plz include explanation in // format .

thnx

Write a program that calculates the average number of days a company's employees are
absent during the year and outputs a report on a file named "employeeAbsences.txt".
Project Specifications
Input for this project:
• the user must enter the number of employees in the company.
• the user must enter as integers for each employee:
o the employee number (ID)
o the number of days that employee missed during the past year.
Input Validation:
• Do not accept a number less than 1 for the number of employees.
• Do not accept a negative number for the days any employee missed.
Be sure to print appropriate error messages for these items if the input is
invalid.
Output: The program should display the following data:
• display a user full name
display a due date
• display the user full name
Each employee number (ID) and the number of days missed should be written
to the report file named "employeeAbsences.txt".
• The average number of days a company's employees are absenting during the
year should be written to the report file named "employeeAbsences.txt".
Processing Requirements
Create a global variable of type ofstream for the output file. Use this variable to
open the file employeeAbsences.txt in your program to write data to it. A global
variable is defined above the main function and its scope is within the entire program.
Create the following three functions that will be called by the main function:
1. A function called NumofEmplovees. This function asks the user for the number
of employees in the company. This value should be returned as an int. The
function accepts no arguments (No parameter/input).
2. A second function called TotDaysAbsent that accepts an arguments of type
int for the number of employees in the company and returns the total of
missed days as an int. This function should do the following:
a. Asks the user to enter the following information for each employee:
The employee number (ID) (Assume the employee number is 4 digits
or fewer, but don't validate it).
The number of days that employee missed during the past year.
Transcribed Image Text:Write a program that calculates the average number of days a company's employees are absent during the year and outputs a report on a file named "employeeAbsences.txt". Project Specifications Input for this project: • the user must enter the number of employees in the company. • the user must enter as integers for each employee: o the employee number (ID) o the number of days that employee missed during the past year. Input Validation: • Do not accept a number less than 1 for the number of employees. • Do not accept a negative number for the days any employee missed. Be sure to print appropriate error messages for these items if the input is invalid. Output: The program should display the following data: • display a user full name display a due date • display the user full name Each employee number (ID) and the number of days missed should be written to the report file named "employeeAbsences.txt". • The average number of days a company's employees are absenting during the year should be written to the report file named "employeeAbsences.txt". Processing Requirements Create a global variable of type ofstream for the output file. Use this variable to open the file employeeAbsences.txt in your program to write data to it. A global variable is defined above the main function and its scope is within the entire program. Create the following three functions that will be called by the main function: 1. A function called NumofEmplovees. This function asks the user for the number of employees in the company. This value should be returned as an int. The function accepts no arguments (No parameter/input). 2. A second function called TotDaysAbsent that accepts an arguments of type int for the number of employees in the company and returns the total of missed days as an int. This function should do the following: a. Asks the user to enter the following information for each employee: The employee number (ID) (Assume the employee number is 4 digits or fewer, but don't validate it). The number of days that employee missed during the past year.
b. Writes each employee number (ID) and the number of days missed to the
output file (employeeAbsences.txt). ( Refer to Sample File Output )
3. A third function called AverageAbsent that calculates the average number of
days absent.
a. The function takes two arguments:
• the number of employees in the company
• The total number of days absent for all employees during the year.
b. This function should return, as a double, the average number of days
absent.
c. This function does not perform screen or file output and does not ask the
user for input.
Sample Screen Output:
| Mark C\windows\system32\cmd.exe
Calculate the average nunber of days a conpany's enployees are absent.
Please enter the nunber of enplo yees in the conpany: 5
Please enter an enployee ID: 1234
Please enter the nunber of days this enployee vas absent: 3
Please enter an enployee ID: 22
Please enter the nunber of days this enployee was absent: 8
Please enter an enployee ID: 667
Please enter the nunber of days this enployee was absent: -5
The nunber of days nust not be negative.
Please re-enter the nunber of days absent: 5
Please enter an enployee ID: 4
Please enter the nunber of days this enployee was absent: 11
Please enter an enployee ID: 9876
Please enter the nunber of days this enployee was absent: 1
Progranner:
Press any key to continue .
insert your nane here
Sample File Output format:
employeeAbsences.bxt + x daysOut.cpp
EMPLOYEE ABSENCE REPORT
days absent
employee id
1234
22
667
5
4
11
9876
1
The 5 employees were absent a total of 20 days.
The average number of days absent is 4.0 days.
Programmer:
insert your name here
Transcribed Image Text:b. Writes each employee number (ID) and the number of days missed to the output file (employeeAbsences.txt). ( Refer to Sample File Output ) 3. A third function called AverageAbsent that calculates the average number of days absent. a. The function takes two arguments: • the number of employees in the company • The total number of days absent for all employees during the year. b. This function should return, as a double, the average number of days absent. c. This function does not perform screen or file output and does not ask the user for input. Sample Screen Output: | Mark C\windows\system32\cmd.exe Calculate the average nunber of days a conpany's enployees are absent. Please enter the nunber of enplo yees in the conpany: 5 Please enter an enployee ID: 1234 Please enter the nunber of days this enployee vas absent: 3 Please enter an enployee ID: 22 Please enter the nunber of days this enployee was absent: 8 Please enter an enployee ID: 667 Please enter the nunber of days this enployee was absent: -5 The nunber of days nust not be negative. Please re-enter the nunber of days absent: 5 Please enter an enployee ID: 4 Please enter the nunber of days this enployee was absent: 11 Please enter an enployee ID: 9876 Please enter the nunber of days this enployee was absent: 1 Progranner: Press any key to continue . insert your nane here Sample File Output format: employeeAbsences.bxt + x daysOut.cpp EMPLOYEE ABSENCE REPORT days absent employee id 1234 22 667 5 4 11 9876 1 The 5 employees were absent a total of 20 days. The average number of days absent is 4.0 days. Programmer: insert your name here
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Binary Search Algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT