Comp 110L

Lab Project #5

Due: 9/21/2009

 

1.            Write a program that plays the popular scissor-rock-paper game.  The program randomly generates a number 0, 1, or 2 representing scissor, rock, and paper.  The program prompts the user to enter a number 0, 1, or 2 and displays a message indicating whether the user or the computer wins or draws.  Note that a scissor can cut a paper, a rock can knock a scissor, and a paper can wrap a rock. (See problem 3.17 on page 100 of the textbook.) 

 

2.            An ISBN (International Standard Book Number) consists of ten digits d1d2d3d4d5d6d7d8d9d10.  The last digit d10 is a checksum, which is calculated from the other nine digits using the following formula.

 

(d1  x 1 + d2 x 2 + d3 x 3 + d4 x 4 + d5 x 5 + d6 x 6 + d7 x 7 + d8 x 8 + d9 x 9 ) % 11

 

If the checksum is 10, the last digit is denoted X according to the ISBN convention.  Write a program that prompts the user to enter the first 9 digits and displays the 10-digit ISBN (including leading zeros).  Your program should read the input as an integer.  (See problem 3.19 on page 100 of the textbook.) 

 

 

For each of the above problems be sure to do the following:

 

1.            Plan your solution by writing down the algorithm to solve the problem before you write the code.

2.            Make sure your programs are self-documented including an appropriate comment header block.

3.            Test the programs by running at least three test cases on each.

 

For each problem, turn in your algorithm design (this can be a skeleton program with comments only or a hand written description of the algorithm), a listing of the program, and a listing of the output from running the test cases.