CST 180 - Lab 4b: Looping

PART A:  do / while loop
Goals:
Modify the pay calculation program (Lab 3) to allow an unlimited number of employees to be processed:

  1. Prompt: "Another employee to process (Y/N) ?"
  2. Store reply and use it to control the loop.
  3. Count the number of employees processed without error.
  4. Accumulate a total payroll amount.
Test Data:
  • Use one cin statement to read all three values.

Program Interaction:

  • These are the inputs and the expected outputs.
  • Anywhere you see ???? requires your program to output some value.
Assignment 5A Programmed by yourname here
Enter Employee #, Pay Code, Hours:
1032864 M 41
Pay Rate:  $??.??        Pay Amount: $???.??
Another employee to process (Y/N)?  y
Enter Employee #, Pay Code, Hours:
1171955 T 38
Pay Rate:  $??.??        Pay Amount: $???.??
Another employee to process (Y/N)?  y
Enter Employee #, Pay Code, Hours:
1224096 O 45
Pay Rate:  $??.??        Pay Amount: $???.??
Another employee to process (Y/N)?  y
Enter Employee #, Pay Code, Hours:
1234567 N 40
INVALID PAY CODE
Pay Rate:  $??.??        Pay Amount: $???.??
Another employee to process (Y/N)?  n

Number of Employees Processed: ??   Total Payroll:  $????.??

 Normal Job Termination

Submit:
  • Source code
  • Output from 4 data sets as shown above


PART B:  for loop
Goals:
Modify Lab 2 to display a table of Fahrenheit temperatures and their Celsius equivalents.
  1. Use a 'for' loop.
  2. Show temperatures ranging from 0o F to 100o F.
  3. Use a ten degree increment in loop.
  4. Display all temperatures to the nearest tenth.
  5. Use precise column alignment.
  6. Display an appropriate title and column headings.
  7. Display END OF REPORT at bottom of the table.
Input:
This is NOT an interactive program.  Use a counter for temperature.

Output:
          TEMPERATURE CONVERSION TABLE

          Fahrenheit           Celsius
          ---------            -------
              0.0               -17.8
             10.0               -12.2
             20.0                -6.7
             30.0                -1.1
             40.0                 4.4
             50.0                10.0
             60.0                15.6
             70.0                21.1
             80.0                26.7
             90.0                32.2
            100.0                37.8

                 END OF REPORT

Submit:

  • Source code listing
  • Output as shown
Return to TOP

! You are using a version 4 browser or older. If you are experiencing any problems with scrolling, please reload the page.