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:
- Prompt: "Another
employee to process (Y/N) ?"
- Store reply
and use it to control the loop.
- Count the
number of employees processed without error.
- Accumulate
a total payroll amount.
Test
Data:
-
Use one cin
statement to read all three values.
Program
Interaction:
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.
- Use a 'for'
loop.
- Show temperatures
ranging from 0o F to 100o F.
- Use a ten
degree increment in loop.
- Display all
temperatures to the nearest tenth.
- Use precise
column alignment.
- Display an
appropriate title and column headings.
- 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
|