As3.doc

advertisement
CSIS 10A
Assignment 3
Read: Hennefeld, Chapter 4
Select 10 Points from below
Due: Start of class, next week
Complete the problems in Lab3If.cpp for up to 11 points (1 pt Extra Credit) When
you are finished, print out the file and turn it in. Store this handout (and graded
labs) in your binder for future reference.
Problems 1 – 10 are worth 10 points. Challenge students may want to do 9 – 12.
PROGRAM TEST PLANS
Problem 9. A) write a program in which the user inputs her age and the output states
whether or not she is a teenager. B) Modify your solution to A) so it also outputs
“invalid age!” if the user enters an age that is negative or over 110. (see test plan)
Test Case
1
2
3
4 (part B)
Input Data
14
5
26
-5 ( or 112)
Expected Result
a teen! wow!
too young
too old
invalid age!
Problem 10.
T-shirts are on sale for $12.00 each if fewer than three are purchased,
$10.00 each if at least three but fewer than ten are purchased, and $7.00 each if at least
ten are purchased. Write a program to input the number of shirts and output the total cost
of the tshirts.
Test Case
1
2
3
Input Data
2
3
10
Expected Result
$ 24
$ 30
$ 70
Problem 11. Write a program that inputs the suit (C, D, H, or S) and rank (1, 2, …13)
of a card and then outputs the rank and suit in words. For example, the inputs D and 1
would result in the output “Ace of Diamonds”, and the inputs H and 13 would result in
the output Queen of Hearts. (see suit.cpp, p75)
Test Case
1
2
3
Input Data
C5
S 12 (do not make it S Q, that's too hard!)
H 13
Expected Result
Five of Clubs
Queen of Spades
King of Hearts
Download