Assign5

advertisement
CSIS 10A
Assignment 5
Read: Hennefeld, Chapter 6
Select 10 Points from below
Name____________________________
Item
Exercises
Ch 6 Exercises 1, 4, 6, 7
Labs
L6-1, L6-4
Ch 6 Programming Problems
Problem 10
Problem 11
Points
4
2 pt
employees.cpp
payVer2.cpp (start w/ pay.cpp)
Challenges
Problem 13
words2digits.cpp
Problem 14 a and b
wordsAnyDigits.cpp
Total Possible
10 points + 1 point extra credit
2
2
4
11
11 max
PROGRAM TEST PLANS
Problem 10
employees.cpp
Test Case
Input Data
Expected Result
see test plan p144
Problem 11
payVer2.cpp
Test Case
Input Data
First last
hours
semester
1
Sal Stern
Ric Ren
Tri Tan
20
15
25
3
6
10
Expected Result in Output File
NAME
Stern, Sal
Ren, Ric
Tan, Tri
HOURS
20
15
25
RATE
4.55
5.30
5.80
PAY
91.00
79.50
145.00
HINTS
Problem 10
employees.cpp
1)
2)
3)
4)
declare variables
declare ifstream fout and open to file employees.txt
output column headings to fout
for loop, 3 times
a. input first, last, age, sex
b. make string last_and_first, a combination of last, comma, and first
c. output last_and_first (left justified), then age and sex (right justified) to
fout, use setw to form even columns
5) close fout
Problem 11
payVer2.cpp
A) in ch06 folder, open pay.cpp, save as payVer2A.cpp
1. modify for loop so it reads first, last, hours, and semesters
2. modify for loop to create last_and_first as in Prob10 step 4b above
3. calculate pay using hours*RATE as it currently does
4. output last_and_first (left justified), then hours, semesters and pay (right
justified) to fout, use setw to form even columns
B) Choose file>SaveAs payVer2B.cpp
1. in for loop, after reading input, calculate newRate using if-else if etc
if(semesters<=0)
output INVALID semesters
else if (semesters<=3)
newRate=RATE;
else if (semesters<=8)
formula for newRate (see p144)
else
newRate=RATE+1.25 (max rate increase at 8 semesters)
2. Better—make a function to calc newRate
Download