CCSU Spring, 2000 Project 2 Posting Date: April 12, 2000 Due Date: April 25, 2000 Do the following: a. The coin matching game: Write a screen based Java application to simulate a coin matching game. The rules are: The computer tosses a pair of coins repeatedly. The computer stops when the two coins match. Use a flag controlled while loop. Use the Math.random() random number generator to generate the coin tosses. Let 0 correspond to Tails and 1 correspond to Heads. After each toss, print the outcome to the screen. Sample output from your program might look like this: HT TH HH b. The sum of integers: Write a screen based Java application to add up the first N integers. Have the user input the value of N. For example, if the user enters 5 for N, your program should find the sum of 1 + 2 + 3 + 4 + 5 and print the result on the screen. Be sure you check that your program produces correct output. Be sure you issue an appropriate prompt before getting the user's value of N. c. Martian dice: On Mars, they use eight sided dice. Their favorite dice game has these rules: The Martian player repeatedly rolls a pair of dice. If he ever rolls a 2, he looses. If he rolls a 9 or 15 on the first roll, he wins. On a subsequent roll, if he rolls a 9, he looses, but if he rolls what he rolled on the first roll he wins. (Sounds a lot like craps, doesn't it?) Write a screen based Java application to simulate a Martian playing dice. Use a flag controlled while loop. Use the Math.random() random number generator to generate the dice rolls. After each roll, print the outcome to the screen. At the end, print whether the Martian has won or lost. For each of the above, hand in design documentation in the form of pseudo-code and/or flowcharts. Of course, you also have to hand in the printed copies of the text of all three classes, as well as a 3.5" floppy disk with the .java and .class files for your classes, as described in project 1. Notes: (1) Your files MUST be named CoinToss.java, SumInt.java and DiceRoll.java so I can find them. (2) Each of your programs must begin with a remark box, as described in project 1. (3) You must use a folder with POCKETS, as described in project 1. (4) Pseudo-code rules: Pseudo-code must be neatly typed on a word processor or text editor, and must be in proper outline form, as illustrated in class. Pseudo-code must reflect a stepwise-refinement design process, and you must hand in at least two separate levels of pseudo-code (in separate documents) reflecting at least a two step refinement process. More levels are always acceptable. (5) Flowcharting rules: Flowcharts must be neatly drawn using plastic templates or flowcharting software. An individual flowchart may not contain more than 7 or 8 boxes; if you need more, break the flowchart into separate modules and flowchart each module separately, as illustrated in class. Flowcharts must have titles, must have a START oval, and must have an EXIT or END oval. Due Tuesday, April 25, 2000 AT THE BEGINNING OF CLASS.