Practice: Looping and Branching

Take out a piece of paper. We’ll be programming on paper.

For the following programming questions, I’d like you to follow the programming algorithm.

1) Read and understand the problem

2) Create the comment stating the problem.

3) Insert the Java boilerplate.

/** Program that ...
 * @author Cam Moore
 */
public class ProgramName {
  /** Does something.
   * @param args the command line arguments.
   */
  public static void main(String[] args) {
    
  }
}

4) Write the steps in pseudo code.

5) Refine the pseudo code.

Problem 1

Write the Number Guess Game program. The program should choose a random number between 1 and 10, then ask the user to guess the number. If their guess is less than the number the program should output “Your guess is less than the number.” If the guess is greater than the number the program should output “Your guess is greater than the number.” If the guess is the number the program should output “Congratulations you guessed the number.”

Show me your code before you leave