Comp 110L

Lab Project #7

Due: 10/12/2009

 

  1. A palindromic prime is a prime number and also palindromic.  For example, 131 is a prime and also a palindromic prime.  So are 5 and 929.  Write a program that displays the first n palindromic prime numbers where n is a number provided by the user.  Display 10 numbers per line and align the numbers properly, as follows:

 

     2    3    5    7   11  101  131  151  181  191

   313  353  373  383  727  757  787  797  919  929

    

     (Compare with problem 3.27 on page 176 of the textbook.)

 

  1. Craps is a popular dice game played in casinos.  Write a program for the following version of the game:

 

Roll two dice.  Each die has six faces representing values 1, 2, . . ., and 6, respectively.  Check the sum of the two dice.  If the sum is 2, 3, or 12 (called craps) you lose; if the sum is 7 or 11 (called natural), you win;  if the sum is another value (i.e., 4, 5, 6, 8, 9, or 10), a point is established.  Continue to roll the dice until either a 7 or the same point value is rolled.  If 7 is rolled, you lose.  Otherwise, you win.

 

 

 

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

 

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

2.            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.