All of the work in this project is my own!  I have not left copies of my code in public folders on university computers. I have not given any of this project to others. I will not give any portion of this project to others taking this class. I realize that the penalty for turning in work that is not my own can range from an "F" in the class to dismissal from Trinity University. 

                                                                                             Print Name  __________________________

                                                                                              Signature   __________________________

                                                                                             Print Name  __________________________

                                                                                              Signature   __________________________
 


PayRoll # 2 Lab
Individual/Team (1-2 Persons) Assignment
20 Points


Set Margins [ Left = 1; Right = .2; Top = .6; Bottom = .6; Select Document Title, Location,  Page Number, Page Total Black Text l]

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!
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[])
{
int 
   EmployeeNo;

double
   PayPerHr,
   HoursWorked,
   Gross,        // Total Money Earned [Time & Half For Over 40 Hrs]
   Tax,          // 30% Tax Rate
   Net;          // Take Home 

// Commercial
   system ("clear");
   cout << "                  PayRoll Calculation System\n";
   cout << "                         written by\n";
   cout << "                             ????\n\n";

   do
   {

// Get Info 
      cout << "\nEmployee No [0 to Exit]: ";   // Comment Out To Read From File
      cin >> EmployeeNo;
      if (EmployeeNo != 0)
      {
         cout << "Pay Per Hour           : ";  // Comment Out To Read From File
         cin >> PayPerHr;
         cout << "# Hours Worked         : ";  // Comment Out To Read From File
         cin >> HoursWorked;

// Calculate Tax, Net, Gross 
         if (HoursWorked <= 40)
            Gross = HoursWorked * PayPerHr ;
         else
            Gross = 40 * PayPerHr + (HoursWorked - 40) * 1.5 * PayPerHr;
         Tax = .30 * Gross;
         Net = Gross - Tax;

// Display Results 
         cout.setf(ios::fixed); 
         cout.setf(ios::showpoint);
         cout.precision(2); 

         cout << "Employee No  : " << EmployeeNo << endl;
         cout << "Hourly Pay   : " << PayPerHr << endl;
         cout << "Hours Worked : " << HoursWorked << endl << endl;

         cout << "Gross : $ " << Gross << endl;
         cout << "Tax   : $ " << Tax << endl;
         cout << "Net   : $ " << Net << endl << endl << endl << endl; 
      }
   }
   while (EmployeeNo != 0); 
   return (0);
}

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:

PayRoll Calculation System
  written by 
????

Employee No  : 10001
Pay Per      : 5.00
Hours Worked : 20.00

Gross : $ 100.00
Tax   : $ 30.00
Net   : $ 70.00
 
 

Employee No  : 10002
Pay Per      : 6.00
Hours Worked : 30.50

Gross : $ 183.00
Tax   : $ 54.90
Net   : $ 128.10
 
 

Employee No  : 10003
Pay Per      : 10.00
Hours Worked : 50.00

Gross : $ 550.00
Tax   : $ 165.00
Net   : $ 385.00
 
 

Employee No  : 10004
Pay Per      : 8.50
Hours Worked : 45.50

Gross : $ 410.13
Tax   : $ 123.04
Net   : $ 287.09

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.



17] Those Labs labeled "Individual Assignment" are to be done separately by each individual. Using a pen,  each individual is to print  his/her name at the top of this document in the space provided and sign it.  Those Labs labeled "Team Assignment" may be done as a team or individually. Using a pen,  each individual on the team is to print print his/her name at the top of this document in the space provided and sign it. Submit only one copy of team assignments!

Include the following in your wire-band binder:

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