Here is my project!

To play craps, a player rolls two dice repeatedly until he wins or loses.

If he makes a 7 or an 11 on the first roll, he wins immediately.

An initial roll of 2, 3, or 12 results in a loss.

If he tosses a 4, 5, 6, 8, 9, or 10 on his first roll, then that number becomes his “point”.

After a player makes a point, he continues rolling the dice and wins or loses according to the

following rules: if he makes his point before rolling a seven, he wins;

but if he rolls a seven first, he loses.

No other values, including 2, 3, 11 or 12, affect the game’s outcome once the player has established his point.

Write a program that plays craps. Your program should allow a user to play more than one game. Typical output appears below:

Enter 0 to roll the dice: 0

You rolled a 7

You win

Play again? Enter 1 for yes: 1

Enter 0 to roll the dice: 0

You rolled a 4.

Your point is 4. Continue rolling.

Enter 0 to roll the dice: 0

You rolled a 3

Enter 0 to roll the dice: 0

You rolled a 5

Enter 0 to roll the dice: 0

You rolled a 7

You lose

Play again? Enter 1 for yes: 0

Bye

Hint: To roll a single die, generate a random number between 1 and 6 inclusive. You can do this with (int)(6 * Math.random()) + 1

Code java:

/** * * Author: Gregory B Shavers * CSC- 225 Online * Lab 5 */ import java.util.*; public class lab5 { public static void main ( String[] args ) { int roll, point_Roll , die1, die2, sumdie, answer; answer = 0; roll = 1; point_Roll = 2; Scanner scan = new Scanner(System.in); do { System.out.println( " Let's play a game of dice. " ); System.out.println( " Enter \"0\" zero to roll the dice. " ); roll = scan.nextInt(); die1 = (int)(6*Math.random())+1; die2 = (int)(6*Math.random())+1; sumdie = die1 + die2; if ( sumdie == 2 || sumdie == 3 || sumdie == 12) { System.out.println( " You rolled a " + sumdie); System.out.println( " You lose! "); } else if ( sumdie == 7 || sumdie == 11) { System.out.println( " You rolled a " + sumdie ); System.out.println( " You win! "); System.out.println( "" ); } else if( sumdie == 1 || sumdie == 4 || sumdie == 5 || sumdie == 6 || sumdie == 8 || sumdie == 9 || sumdie == 10) { System.out.println(" "); System.out.println( " You rolled a " + sumdie ); System.out.println( " This is your point roll: " + sumdie ); System.out.println( " " ); do { System.out.println( " Please enter \"0\" zero to roll the dice again. " ); System.out.println( " You rolled a: " + point_Roll ); point_Roll = scan.nextInt(); System.out.println( " " ); die1 = (int)(6*Math.random())+1; die2 = (int)(6*Math.random())+1; point_Roll = die1 + die2; if(point_Roll == 7) { System.out.println( " You rolled a " + point_Roll ); System.out.println( " You lose! " ); } else if (point_Roll == sumdie) { System.out.println( " You rolled a " + point_Roll); System.out.println( " You win! " ); } }while ( point_Roll != sumdie || point_Roll != 7 ); } do { System.out.println( " Play again? 1 for YES; 0 for NO: " ); roll = scan.nextInt(); System.out.print(" "); }while( roll != 1 && answer != 0); }while( roll == 1 ); System.out.println( " Thanks for playing. " ); } }

Here is my output below.

Let's play a game of dice.

Enter "0" zero to roll the dice.

0

You rolled a 4

This is your point roll: 4

Please enter "0" zero to roll the dice again.

You rolled a: 0

0

Please enter "0" zero to roll the dice again.

You rolled a: 12

0

Please enter "0" zero to roll the dice again.

You rolled a: 6

0

You rolled a 7 You lose!

Play again? 1 for YES; 0 for NO: 1

Please enter "0" zero to roll the dice again.

You rolled a: 7

0

You rolled a 7 You lose!

Play again? 1 for YES; 0 for NO: 1

Please enter "0" zero to roll the dice again.

You rolled a: 7

0

Please enter "0" zero to roll the dice again.

You rolled a: 8

0

Please enter "0" zero to roll the dice again.

You rolled a: 6

0

You rolled a 4

You win!

Play again? 1 for YES; 0 for NO:

I know I made a fundamental error but I don't know what. Can any one please help??

Thanks Again!