CS 201
Program 09

Due: Monday, April 23rd, 2012.

Main topics: Boolean expressions
if & if - else statements
While loops
User defined methods

Program Specification:

There is a "fun" children's game where one child thinks of a "common phrase", then the second child repeatedly makes guesses as to the letters that it contains.

You are to write a Java program that:

  1. Prompts a user to enter a "common phrase", and reads it into a String variable using Scanner.nextLine() - under the assumption that the phrase consists of nothing but undercase letters and spaces.

  2. A second String variable, expSoFar, is constructed such that:
    1. It has the same length as the "common phrase".

    2. It contains spaces everywhere that the "common phrase" does.

    3. All its other characters are the '?' character.

  3. The following is than repeated until the entire "common phrase" is exposed:

Requirenments:

Grading:

Performance Indicator [1] [2] [3]
Readability and documentation 0 1 1
Use of loops 1 2 2
Use of methods 1 2 2
Functional requirements 2 3 4
Efficiency 0 1 1

Sample run(s):

Please enter the phrase to guess at : who do you love



Common Phrase
-------------
??? ?? ??? ????


Enter a lowercase letter guess : f



Common Phrase
-------------
??? ?? ??? ????


Enter a lowercase letter guess : o



Common Phrase
-------------
??o ?o ?o? ?o??


Enter a lowercase letter guess : s



Common Phrase
-------------
??o ?o ?o? ?o??


Enter a lowercase letter guess : w



Common Phrase
-------------
w?o ?o ?o? ?o??


Enter a lowercase letter guess : h



Common Phrase
-------------
who ?o ?o? ?o??


Enter a lowercase letter guess : d



Common Phrase
-------------
who do ?o? ?o??


Enter a lowercase letter guess : e



Common Phrase
-------------
who do ?o? ?o?e


Enter a lowercase letter guess : y



Common Phrase
-------------
who do yo? ?o?e


Enter a lowercase letter guess : u



Common Phrase
-------------
who do you ?o?e


Enter a lowercase letter guess : l



Common Phrase
-------------
who do you lo?e


Enter a lowercase letter guess : v



Common Phrase
-------------
who do you love

Submission:

  1. Use a web browser to Open D2L: https://uwm.courses.wisconsin.edu/

  2. Log in.

  3. From 2122 - Spring 2012
    CEAS-Computer Science
    Select Intro Computer Programming

  4. Select Dropbox.

  5. Select the Program 09 drop box.

  6. Click the Add a File button.

  7. In the Submit a File pop-up window, click the Browse button.

  8. In the File Upload pop-up window, Locate and click on your Java source code file: e.g. Prog09.java.

  9. In the File Upload pop-up window, click the Open button.

  10. In the Submit a File pop-up window, Click the upload button.



Robert D. Sorenson 2012-04-16