We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,985 Members — Technology Publication meets Social Media

# Java Dice Game

Inline Code Example Here import java.util.*;

``````public class DiceGame {

public static void main(String[] args){

Random myRand = new Random();
Scanner myScan = new Scanner(System.in);
double money = 10.00;
int temp2 = myRand.nextInt(6)+ 1;
int temp3 = myRand.nextInt(6)+ 1;
int roll = temp2 + temp3;
int choice = 0;
boolean stop = 0;

choice = myScan.nextInt();

while(choice==1&&stop==0){
if(roll % 2==0){
System.out.println("You win .50!!Would you like to roll again? Press 0 for stop and 1 to TRY YOUR LUCK!!!");
(money + .50);
}else{
System.out.println("You lose!  Would you like to roll again?");
(money - .50);
}

}
while(choice==2&&stop==0){
if(roll % 2!=0){
System.out.println("You win .50!!");
(money + .50);

} else{
(money - .50);
}

while(choice==3&&stop==0){
if(temp2==temp3){
System.out.println("Yay you got DOUBLES!!!!  You win \$2.00!!");
(money + 2.00);
}else{
System.out.println("Sorry you lose \$2.00.  Would you like to roll again??? Enter 0 for No or 1 for Yes");
(money - 2.00);
}

while(choice==4&&stop==0){
System.out.println("What is the guess of your next roll???");

System.out.println(temp2);
System.out.println(temp3);
}

public static void printLines
System.out.println("This is how much money you have to play \$" + money + " !!!!");
System.out.println("Would you like to bet .50 for even?: Enter 1");
System.out.println("Would you like to bet .50 for odd? Enter 2");
System.out.println("Would you like to bet \$2.00 for doubles? Enter 3");
System.out.println("Would you like to bet \$5.00 for exact amount? Enter 4 and enter exact amount.");

}
``````
2
Contributors
1
5 Hours
Discussion Span
6 Months Ago
Last Updated
2
Views
sandrannola
Newbie Poster
1 post since Oct 2012
Reputation Points: 0
Skill Endorsements: 0

Please specify the problem that you are facing..?? what exactly do you want?

DJSAN10
Posting Whiz in Training
260 posts since Dec 2010
Reputation Points: 38