Lab 2

Lab assignment: Game of Pig (text version)

Write a program in Java that allows two users play Game of Pig 

This example prints out a welcome message, gets a random number between 1..6 (inclusive) and prints it out, then gives a goodbye message. It provides you a starting point.

For 1 point: :

We add code to generate a random number in a loop. Each time through the loop we prompt the user to continue ('c') or exit ('x').

For 2 points: :

The program sums the random numbers each time through the loop into a variable, and when the user exits the program it displays the total. After that is working, they should add an if statement so that the 

program breaks out of the loop when the random number is 1 (using a "break" statement), otherwise adds the random number to the score.

For 3 points: :

Program allows two users to play against each other.

Work on this assignment in pairs, put your name and UIN in your program, submit your program (.java file) to Blackboard->Assignment-> Lab 2

/*************************************/

Helpful Tips for writing a loop:

for(start_value ; condition ; update_value){

      the_operation_you_want_to_loop

}

example:

for(int i=0; i<10; i++){

      System.out.println(i);

}

/*

This piece of code will print 

0

1

2

3

4

5

6

7

8

9

*/

/***********************************/