Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi, i am creating a java craps game, and i am almost done with it. i just need t

ID: 3544444 • Letter: H

Question

Hi, i am creating a java craps game, and i am almost done with it. i just need the game to do these thing:





public class Craps1 {



    public static void main(String[] args) {

      


boolean flag = true;


while(flag)


{


flag = playOneGame();


}


}



public static int rollDie(int a)


{


Random rand=new Random();


return (rand.nextInt(5) * a)+1;


}



public static int rollDice()


{


int temp = (rollDie(6) + (rollDie(6)));


System.out.println(temp);


return temp;


}



public static boolean playOneGame()


{


int sum = rollDice();


if(sum == 7 || sum == 11)


{


return true;


}



else if(sum == 2 || sum == 3 || sum == 12 )


{


return false;


}


else


{



while(sum == 7)

{

System.out.println("you lose");

{

Explanation / Answer

public class CrapsGame {

public static void main(String[] args) {

int dice1 = (int)(Math.random()* 6) + 1;

int dice2 = (int)(Math.random()* 6) + 1;

int roll = dice1 + dice2;

System.out.println();

System.out.print("You rolled "+roll+". ");

if(roll == 2 || roll == 3 || roll == 12){

System.out.println("You Lose !");

}else if(roll == 7 || roll == 11){

System.out.println("You Win !");

}else{

System.out.println("Point is "+roll+" ");

dice1 = (int)(Math.random()* 6) + 1;

dice2 = (int)(Math.random()* 6) + 1;

int roll2 = dice1 + dice2;

System.out.print("You rolled "+roll2+". ");

while(roll2 != 7){

if(roll == roll2){

System.out.println("You Win !");

break;

}else{

System.out.println("Point is "+roll+" ");

}

dice1 = (int)(Math.random()* 6) + 1;

dice2 = (int)(Math.random()* 6) + 1;

roll2 = dice1 + dice2;

System.out.print("You rolled "+roll2+". ");

}

if(roll2 == 7){

System.out.println("You Lose !");

}

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote