Print Name __________________________
Signature __________________________
Print Name __________________________
Signature __________________________
PayRoll # 2 Lab
Individual/Team (1-2 Persons) Assignment
20 Points
We shall first make this program work interactively and then transform it into a program that works from an input file. You have most of the logic completed in PayRoll1.cpp lab. Use that code!
Implement and test one module at a time!
Implement and test one module at a time!
Implement and test one module at a time!
Implement and test one module at a time!
Implement and test one module at a time!
1] Transform the following PayRoll Program into a modular/functional
program which contains modules/functions called ClearScreen, Commercial,
GetInfo, Calculate, and DisplayInfo. Call the program PayRoll2.cpp
You will find a working copy of
PayRoll1.cpp below! Note that a loop has been included!
| # include <iostream.h>
# include <stdlib.h> # include <iostream.h> main (int argc, char * argv[])
double
// Commercial
do
// Get Info
// Calculate Tax, Net, Gross
// Display Results
cout << "Employee No : " << EmployeeNo << endl;
cout << "Gross : $ " << Gross << endl;
|
2] Module main should contain the following variables at the top:
main (int argc, char * argv[])
{
int
EmployeeNo;
double
PayPerHr,
HoursWorked,
Gross,
Tax,
Net;
Each and every program file that you turn in this
semester shall contain a documentation block at the top.
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
///
PayRoll2.cpp
//
///
//
/// Purpose : Calculate
Net, Gross, and Tax for Employee PayRoll System.
//
///
//
/// Written By : Dr. Thomas E. Hicks
Environment : Linux //
/// Date
: 2/10/02
Compiler : g++
//
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
3] Module ClearScreen is to clear the UNIX/Linux console
screen.
Each and every module that you turn in this semester
shall contain a documentation block immediately above the module code. For this
module I might suggest the following:
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//
ClearScreen
//
//
//
// Purpose : Clear the
console window on a UNIX/Linux System.
//
//
//
// Written By : Dr. Thomas E. Hicks
Environment : Linux //
// Date
: 2/10/02
Compiler : g++
//
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
4] Module Commercial is to display
PayRoll Calculation System
written by
????
centered - near the middle of an 80 character wide window.
Replace the ???? with your name.
Each and every module that you turn in this semester
shall contain a documentation block immediately above the module code. For this
module I might suggest the following:
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//
Commercial
//
//
//
// Purpose : Display a
program banner on a clear screen. Banner includes
//
// PayRoll
Calculation System and author(s).
//
//
//
// Written By : Dr. Thomas E. Hicks
Environment : Linux //
// Date
: 2/10/02
Compiler : g++
//
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
5] Module GetInfo needs to be passed variables EmployeeNo, PayPerHr, & HoursWorked. Its job is to fill those variables with cin.
Each and every module that you turn in this semester
shall contain a documentation block immediately above the module code. For this
module I might suggest the following:
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//
GetInfo
//
//
//
// Purpose : Interactively
prompt the user for EmployeeNo, PayPerHr, and
//
// HoursWorked.
Immediately stop if EmployeeNo = 0.
//
//
//
// Written By : Dr. Thomas E. Hicks
Environment : Linux //
// Date
: 2/10/02
Compiler : g++
//
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
6] Module Calculate will use variables PayPerHr, & HoursWorked to calculate Gross, Tax,& Net. This module must be passed all six of these variables. Pay time and a half for all hours over 40. Tax Rate = 30 % for all.
Each and every module that you turn in this semester
shall contain a documentation block immediately above the module code. For this
module I might suggest the following:
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//
Calculate
//
//
//
// Purpose : Use the
PayPerHr and HoursWorked to Calculate the Gross, Tax
//
// and
Net. Pay time and a half for overtime.
//
//
//
// Written By : Dr. Thomas E. Hicks
Environment : Linux //
// Date
: 2/10/02
Compiler : g++
//
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
7] Module Display Info must be passed variables EmployeeNo,
PayPerHr, HoursWorked , Gross,
Tax,&
Net.
Each and every module that you turn in this semester
shall contain a documentation block immediately above the module code. For this
module I might suggest the following:
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
//
Display
//
//
//
// Purpose : Neatly
display the program
information.
//
//
//
// Employee No : 10001
//
// Pay Per : 5.00
//
// Hours Worked : 20.00
//
//
//
// Gross : $ 100.00
//
// Tax : $ 30.00
//
// Net : $ 70.00
//
//
//
//
//
// Written By : Dr. Thomas E. Hicks
Environment : Linux //
// Date
: 2/10/02
Compiler : g++
//
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
Actual program execution should produce output similar to that below:
|
written by ???? Employee No : 10001
Gross : $ 100.00
Employee No : 10002
Gross : $ 183.00
Employee No : 10003
Gross : $ 550.00
Employee No : 10004
Gross : $ 410.13
|
8] Module/Function main shall (1) call/evoke module Commercial, (2) and continue to call/evoke GetInfo -- if EmployeeNo is not 0 then (a) call/evoke Calculate and (b) call/evoke DisplayInfo --- until the EmployeeNo = 0. Implement and test one module at a time!
9]Test your program. Enter the following from keyboard!
10001 5 20
10002 6 30.5
10003 10 50
10004 8.50 45.5
0
Batch Program [Runs From
A File!]
10] Copy PayRoll2.cpp
to PayRoll3.cpp
11] Create your own data file to test the program. The datafile must contain at least three sets of Employee Information. Each line of the file will contain an EmployeeNo, PayPerHr, and HoursWorked. Separate each with a blank. You could use the example below. Let us assume that the file is called PayRoll1Data
10001 5 20
10002 6 30.5
10003 10 50
10004 8.50 45.5
0
12] Comment out the following lines in GetInfo
// cout <<
"\nEmployee No [0 to Exit]: "; // Comment Out To Read From
File
// cout <<
"Pay Per Hour
: "; // Comment Out To Read From File
// cout <<
"# Hours Worked : ";
// Comment Out To Read From File
13] The program will be compiled with the following line
of code:
g++ PayRoll2.cpp
14] The program will be executed with the following line
of code:
a.out < PayrollData
15] The following line of code will execute your program
and send the output to a file called Output.txt
a.out < PayrollData > Output.txt
14] Start Windows 2000/NT/98/95 Print PayRoll2.cpp & PayRoll3.cpp in Courier 8 Point Fonts!
Visual C++ Printing: Page SetUp & Font Selection
16] Copy files PayRoll2.cpp & PayRoll3.cpp to a floppy
disk. Copy files PayRoll2.cpp & PayRoll3.cpp to
a second floppy disk. Keep one of these disks as a backup.
A] Divider
B] Copy of this assignment sheet. Using an ink pen, print your name and sign this lab at the top.
C] PayRoll2.cpp & PayRoll3.cpp printouts
D] Disk containing the files PayRoll2.cpp & PayRoll3.cpp