Professional Documents
Culture Documents
CMSC140_Project4v2(3)
CMSC140_Project4v2(3)
CMSC140_Project4v2(3)
Chapters Covered:
Chapters from 1 to 6
Project Description
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:
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.
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 prototypes and functions definitions that will be
called by the main function:
o All these functions MUST be defined above main function.
1
1. A function called getNumOfEmployees. 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).
Asks the user to enter the following information for each employee:
Writes each employee number (ID) and the number of days missed
to the output file (employeeAbsences.txt).
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 yours .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 the 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.
General Requirements:
Include the following in your code in C++ source .cpp:
o Program Header: All programming projects’ source code need to have one block
comment at the top of the program containing the course name and CRN, the project
2
number, your name, project description, and the due date. Provide any additional
comments as necessary to clarify the program.
/*
* Class: CMSC140 CRN
* Instructor:
* Project<number>
* Description: (Give a brief description for Project)
* Due Date:
* I pledge that I have completed the programming assignment
independently.
I have not copied the code from a student or any source.
I have not given my code to any student.
Print your Name here: __________
*/
o Indentation: It must be consistent throughout the program and must reflect the
control structure.
o 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).
o Comments: If your variable/constant names are not descriptive to show the role
of the variable or method, add comment to variables, formulas, or any part of the
program with the purpose of making the source code easier to understand.
3
Sample File Output format:
4
Deliverables:
Intermediate deliverable:
Program design- Flowchart and Pseudocode for the Program due one week after
project is given. An intermediate assignment will be created for submission.
Flowchart/pseudo code can be submitted electronically in the following format:
word document, pdf or handwritten flowchart/pseudo code picture saved as .jpg
or png.
Project 4 Implementation deliverables (due one week after Project Design
submitted).
o Write about your Learning Experience, highlighting your lessons learned and learning
experience from working on this project.
o What have you learned?
o What did you struggle with?
o What would you do differently on your next project?
o What parts of this assignment were you successful with, and what parts (if any) were
you not successful with?
o Provide any additional resources/links/videos you used to while working on this
assignment/project.
[3.] FirstInitialLastName_Pr4.zip, a compressed file containing your C++ file. This folder should
contain C++ source file FirstInitialLastName_Pr4.cpp only and should not contain any other file
or folder.
[4.]
[5.]