employeeAbsences.bxt # × daysOut.cpp EMPLOYEE ABSENCE REPORT employee id 1234 days absent 3 22 667 4 11 9876 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

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section8.3: Random File Access
Problem 6E
icon
Related questions
Question

c++ 

Processing Requirements
Create a variable of type ofstream inside main for the output file. Use this variable to
open the file employeeAbsences.txt in your main program to write data to it.
Create the following three functions that will be called by the main function:
1. A function called numofEmployees. 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 arguments of type int
for the number of employees in the company and a reference argument of type
ofstream, 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.
NOTE:
The location of the file employeeAbsences.txt created by your program will be in
the same folder as your .cpp source file. Make sure to check your file system
directory to see if the file is getting created as the result of running your program
and its format matches with the format shown in Sample File output format.
Also avoid declaring an absolute path for employeeAbsences.txt, for example
e:\\ employeeAbsences.txt or c:\\cmsc140\\employeeAbsences.txt in your
program].
Transcribed Image Text:Processing Requirements Create a variable of type ofstream inside main for the output file. Use this variable to open the file employeeAbsences.txt in your main program to write data to it. Create the following three functions that will be called by the main function: 1. A function called numofEmployees. 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 arguments of type int for the number of employees in the company and a reference argument of type ofstream, 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. NOTE: The location of the file employeeAbsences.txt created by your program will be in the same folder as your .cpp source file. Make sure to check your file system directory to see if the file is getting created as the result of running your program and its format matches with the format shown in Sample File output format. Also avoid declaring an absolute path for employeeAbsences.txt, for example e:\\ employeeAbsences.txt or c:\\cmsc140\\employeeAbsences.txt in your program].
+
bb-montgomerycollege.blackboard.com
| LOW BATTERY
12:50 AM
Your Mac will sleep soon unless plugged into a
Bb Upload Assignment: Project #4 Design or Temporary Files &ndash...
Bb https://bb-montgomerycollege.blackboard.com/bbcswebdav/pid-6.
Bb htt
power outlet.
Sample Screen Output:
Test Plan Template
Test your program with at least 3 more test cases. Use the given data as an example.
Record your data for input and output in the following table. Make sure your tests
cover all the possible scenarios.
CA. Mark C:\windows\system32\cmd.exe
Calculate the average number of days a company's employees are absent.
Test
Case #
Please enter the number of employees in the company: 5
Please enter an employee ID: 1234
Please enter the number of days this employee was absent: 3
Please enter an employee ID: 22
Please enter the number of days this employee was absent: 0
Please enter an employee ID: 667
Please enter the number of days this employee was absent: -5
The number of days must not be negative.
Please re-enter the number of days absent: 5
Please enter an employee ID: 4
Please enter the number of days this employee was absent: 11
Please enter an employee ID: 9876
Please enter the number of days this employee was absent: 1
Programmer:
Press any key to continue
Input
Output
No. of employees
Employee ID's/Days of absence
1
4
Total: 16
1111
4
Average: 4.0
1112
1113
1114
4
3
No. of employees
Employee ID's/Days of absence
5
Total: 25
Average: 5.0
2
1234
2
insert your name here
2234
4
3234
6
4234
5234
4
3
4
Sample File Output format:
Project Submission Requirements
employeeAbsences.txt +
x daysOut.cpp
EMPLOYEE ABSENCE REPORT
employee id
Deliverables:
days absent
C++ files (source code)
Output file
Documentation file
1234
3
22
667
4
11
9876
1
Deliverables Format:
The above deliverables will be packaged as follows:
The 5 employees were absent a total of 20 days.
The average number of days absent is 4.0 days.
C++ files (source code): FirstInitialLastName_Pr<number>.cpp
Output file called employeeAbsences.txt
Documentation: Word document(docx) or .pdf including:
Programmer:
insert your name here
Title page including student name, project title and number
Comments: Add comment to variables, formulas, or any part of the program with the
purpose of making the source code easier to understand.
Flowchart
Pseudocode
Test plan (table) with at least 3 different data sets and screenshots
Indentation: It must be consistent throughout the program and must reflect the control
supporting each test case
Lessons Learned Section describing any issues you experienced during
work on the project and how you solve them.
structure.
Proper naming conventions: Variable and method names need to be descriptive to show
the role of the variable or method. Avoid single letter names. Constant names should be
all upper-case, variable names should use "camel case" (i.e. start with lower case, with
subsequent words starting with upper case: hoursWorked for example) or underscores
to separate words (i.e. items_ordered).
Transcribed Image Text:+ bb-montgomerycollege.blackboard.com | LOW BATTERY 12:50 AM Your Mac will sleep soon unless plugged into a Bb Upload Assignment: Project #4 Design or Temporary Files &ndash... Bb https://bb-montgomerycollege.blackboard.com/bbcswebdav/pid-6. Bb htt power outlet. Sample Screen Output: Test Plan Template Test your program with at least 3 more test cases. Use the given data as an example. Record your data for input and output in the following table. Make sure your tests cover all the possible scenarios. CA. Mark C:\windows\system32\cmd.exe Calculate the average number of days a company's employees are absent. Test Case # Please enter the number of employees in the company: 5 Please enter an employee ID: 1234 Please enter the number of days this employee was absent: 3 Please enter an employee ID: 22 Please enter the number of days this employee was absent: 0 Please enter an employee ID: 667 Please enter the number of days this employee was absent: -5 The number of days must not be negative. Please re-enter the number of days absent: 5 Please enter an employee ID: 4 Please enter the number of days this employee was absent: 11 Please enter an employee ID: 9876 Please enter the number of days this employee was absent: 1 Programmer: Press any key to continue Input Output No. of employees Employee ID's/Days of absence 1 4 Total: 16 1111 4 Average: 4.0 1112 1113 1114 4 3 No. of employees Employee ID's/Days of absence 5 Total: 25 Average: 5.0 2 1234 2 insert your name here 2234 4 3234 6 4234 5234 4 3 4 Sample File Output format: Project Submission Requirements employeeAbsences.txt + x daysOut.cpp EMPLOYEE ABSENCE REPORT employee id Deliverables: days absent C++ files (source code) Output file Documentation file 1234 3 22 667 4 11 9876 1 Deliverables Format: The above deliverables will be packaged as follows: The 5 employees were absent a total of 20 days. The average number of days absent is 4.0 days. C++ files (source code): FirstInitialLastName_Pr<number>.cpp Output file called employeeAbsences.txt Documentation: Word document(docx) or .pdf including: Programmer: insert your name here Title page including student name, project title and number Comments: Add comment to variables, formulas, or any part of the program with the purpose of making the source code easier to understand. Flowchart Pseudocode Test plan (table) with at least 3 different data sets and screenshots Indentation: It must be consistent throughout the program and must reflect the control supporting each test case Lessons Learned Section describing any issues you experienced during work on the project and how you solve them. structure. Proper naming conventions: Variable and method names need to be descriptive to show the role of the variable or method. Avoid single letter names. Constant names should be all upper-case, variable names should use "camel case" (i.e. start with lower case, with subsequent words starting with upper case: hoursWorked for example) or underscores to separate words (i.e. items_ordered).
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
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
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr