CS 2073 Lab 3: Weekly Payroll Calculation, Lab Reports of Computer Science

The instructions for lab 3 of cs 2073 at utsa, where students are required to write a program to calculate the weekly pay for different types of employees based on their paycodes. The objectives, hand-in requirements, details, setup, and coding process.

Typology: Lab Reports

Pre 2010

Uploaded on 07/31/2009

koofers-user-pef
koofers-user-pef 🇺🇸

8 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 2073 Lab 3: Multiple Selection
Chia-Tien Dan Lo
Department of Computer Science, UTSA
I Objectives
Demonstrate your ability to read data from the user of your program
Show the usage of a while repetition structure with a sentinel value
Use a multiple selection structure to sort out different cases
II Hand-in Requirements
All laboratories will be submitted electronically through WebCT. Zip up your entire project folder to submit as the
source. (Right click on the laboratory folder and follow the SentTo link.)
III Details
A company pays its employees as managers (who receive a fixed weekly salary), hourly workers (who receive a fixed
hourly wage for up to the first 40 hours they work and “time-and-a-half”— i.e., 1.5 times their hourly wage for
overtime hours worked), commission workers (who receive $250 plus 5.7% of their gross weekly sales), or pieceworkers
(who receive a fixed amount of money for each of the items they produce each pieceworker in this company works
on only one type of item). Write a program to compute the weekly pay for each employee. You do not know the
number of employees in advance. Each type of employee has its own pay code: Managers have paycode 1, hourly
workers have code 2, commission workers have code 3 and pieceworkers have code 4. Use a switch to compute each
employee’s pay based on that employee’s paycode. Within the switch, prompt the user (i.e., the payroll clerk) to
enter the appropriate facts your program needs to calculate each employee’s pay based on that employee’s paycode.
IV Setup
1. Pro ject name: Lab3
2. Solution name: MyCPrograms
3. Create a new source with name: main.c
4. Save the source
5. Compile and run the program.
V Coding
1. Write a main function shell just like the Hello World project.
2. Write down comments whenever applicable.
3. Declare the following variables:
int payCode; /* current employee’s pay code */
int managers = 0; /* total number of managers */
int hWorkers = 0; /* total number of hourly workers */
int cWorkers = 0; /* total number of commission workers */
1
pf2

Partial preview of the text

Download CS 2073 Lab 3: Weekly Payroll Calculation and more Lab Reports Computer Science in PDF only on Docsity!

CS 2073 Lab 3: Multiple Selection

Chia-Tien Dan Lo

Department of Computer Science, UTSA

I Objectives

  • Demonstrate your ability to read data from the user of your program
  • Show the usage of a while repetition structure with a sentinel value
  • Use a multiple selection structure to sort out different cases

II Hand-in Requirements

All laboratories will be submitted electronically through WebCT. Zip up your entire project folder to submit as the source. (Right click on the laboratory folder and follow the SentTo link.)

III Details

A company pays its employees as managers (who receive a fixed weekly salary), hourly workers (who receive a fixed hourly wage for up to the first 40 hours they work and “time-and-a-half”— i.e., 1.5 times their hourly wage — for overtime hours worked), commission workers (who receive $250 plus 5.7% of their gross weekly sales), or pieceworkers (who receive a fixed amount of money for each of the items they produce — each pieceworker in this company works on only one type of item). Write a program to compute the weekly pay for each employee. You do not know the number of employees in advance. Each type of employee has its own pay code: Managers have paycode 1, hourly workers have code 2, commission workers have code 3 and pieceworkers have code 4. Use a switch to compute each employee’s pay based on that employee’s paycode. Within the switch, prompt the user (i.e., the payroll clerk) to enter the appropriate facts your program needs to calculate each employee’s pay based on that employee’s paycode.

IV Setup

  1. Project name: Lab
  2. Solution name: MyCPrograms
  3. Create a new source with name: main.c
  4. Save the source
  5. Compile and run the program.

V Coding

  1. Write a main function shell just like the Hello World project.
  2. Write down comments whenever applicable.
  3. Declare the following variables:

int payCode; /* current employee’s pay code / int managers = 0; / total number of managers / int hWorkers = 0; / total number of hourly workers / int cWorkers = 0; / total number of commission workers */

int pWorkers = 0; /* total number of pieceworkers / int pieces; / current pieceworkder’s number of pieces / double mSalary; / manager’s salary / double hSalray; / hourly worker’s salary / double cSalary; / commission worker’s salary / double pSalary; / pieceworker’s salary / double hours; / total hours worked / double otPay; / overtime pay / double otHours; / overtime hours / double pay; / current employee’s weekly pay */

  1. Prompt for first employee input and read keyboard input for payCode
  2. Create a while loop and check if a sentinel value of -1 is read
  3. Write a switch statement on payCode, compute, and print salaries accordingly.
  4. Update statistics variables such as managers, hWorkers, cWorkers, pWorkers
  5. Add a default case for handling “Invalid pay code”.
  6. After loop terminates, print out statistical counts for each type of employee with suitable labels.

VI Testing

Compile and run your program until there are no errors. You may test your program at least once on each case.