play three games of this and the compiler somehow subtracts Winner and Winner2, making them 1 game off or so...
Code:import java.util.Random;
import java.util.Scanner;
public class DiceGame
{
public static void main( String args[] )
{
Random randomNumbers = new Random();
int face;
int face2;
int face3;
int face4;
int sum;
int sum2;
int sum3;
int sum4;
@SuppressWarnings("unused")
int sum5;
int NumberRoll;
int Go;
int Games;
int Winner;
int Winner2;
int Ties;
String Name;
String Name2;
Games = 1;
Winner = 0;
Winner2 = 0;
Ties = 0;
for ( int counter = 1; counter <= 1; counter++ )
{
System.out.printf( "Welcome to a game of Big Dice!\nHave Fun!\n\n" );
Scanner input = new Scanner( System.in );
System.out.printf( "Player1 please enter your first name:\n" );
Name = input.next();
System.out.printf( "Please enter your first name Player2:\n" );
Name2 = input.next();
System.out.printf( "\nWhats the highest number you want your dice to roll(or 926620 for rules):\n" );
NumberRoll = input.nextInt();
if ( NumberRoll == 926620 )
System.out.println( "Rules List!\n\n1. Have Fun\n2. Show your friends this game\n" +
"3. Listen to Linkin Park\n4. Win and Have Fun!\n" );
if ( NumberRoll == 444444 )
System.out.println( "Merry Christmas!\n\nI LOVE YOU!\n" );
System.out.printf( "\n%s's Rolls\n", Name );
face = 1 + randomNumbers.nextInt( NumberRoll );
System.out.printf( "%d\n", face );
face2 = 1 + randomNumbers.nextInt( NumberRoll );
System.out.printf( "%d\n", face2 );
System.out.printf( "%s's Rolls\n", Name2 );
face3 = 1 + randomNumbers.nextInt( NumberRoll );
System.out.printf( "%d\n", face3 );
face4 = 1 + randomNumbers.nextInt( NumberRoll );
System.out.printf( "%d\n\n", face4 );
sum = face + face2;
sum2 = face3 + face4;
sum3 = Winner - Winner2;
sum4 = Winner2 - Winner;
sum5 = Winner + Winner2;
if ( sum2 == sum )
{
Ties = Ties + 1;
}
if ( sum > sum2 )
{
Winner = Winner + 1;
}
if ( sum2 > sum )
{
Winner2 = Winner2 + 1;
}
if ( sum == 24 )
sum = face + face2 * 2;
if ( sum == 24 )
System.out.printf( "%s, has rolled a lucky number, now %d multiplies by two!\n", Name, sum );
if ( sum == 62 )
sum = face2 + face2 * 2;
if ( sum == 62 )
System.out.printf( "%s, has rolled a lucky number, now %d multiplies by two!\n", Name, sum );
if ( sum2 == 17 )
sum2 = face3 + face4 * 2;
if ( sum2 == 17 )
System.out.printf( "%s, has rolled a lucky number, now %d multiplies by two!\n", Name2, sum2 );
if ( sum2 == 85 )
sum2 = face3 + face4 * 2;
if ( sum2 == 85 )
System.out.printf( "%s, has rolled a lucky number, now %d multiplies by two!\n", Name2, sum2 );
System.out.printf( "The sum for %s is %d\n", Name, sum );
System.out.printf( "The sum for %s is %d\n", Name2, sum2 );
if ( sum > sum2 )
System.out.printf( "%s has won the game!\n", Name );
if ( sum2 > sum )
System.out.printf( "%s has won the game!\n\n", Name2 );
if ( sum == sum2 )
System.out.println( "Tie!" );
if ( face == face2 )
System.out.printf( "%s has rolled the same two numbers, %d, and %d,\n The chances of doing that are %d to 1!\n", Name, face, face2, NumberRoll);
if ( face3 == face4 )
System.out.printf( "%s has rolled the same two numbers, %d, and %d,\n The chances of doing that are %d to 1!\n\n", Name2, face3, face4, NumberRoll );
if ( sum > sum2 )
System.out.printf( "Congradulations %s, you have won a game of Big Dice!\n\n", Name );
if ( sum < sum2 )
System.out.printf( "Congradulations %s, you have won a game of Big Dice!\n\n", Name2 );
System.out.printf( "Enter 1 if you would like to play again, enter 2 if you want to quit:\n" );
Go = input.nextInt ();
if ( Go == 4 )
System.out.println( "You are in luck, that is my lucky number! " );
if ( Go == 2 )
System.out.printf( "\nGoodebye %s and %s, it was enjoyable watching you two play together. ", Name, Name2 );
while ( Go != 2 )
{
System.out.printf( "\n\nWelcome back %s, and, %s!\nHave Fun!\n\n", Name, Name2 );
new Scanner( System.in );
System.out.printf( "Whats the highest number you want your dice to roll:\n" );
NumberRoll = input.nextInt();
System.out.printf( "\n%s's Rolls\n", Name );
face = 1 + randomNumbers.nextInt( NumberRoll );
System.out.printf( "%d\n", face );
face2 = 1 + randomNumbers.nextInt( NumberRoll );
System.out.printf( "%d\n", face2 );
System.out.printf( "%s's Rolls\n", Name2 );
face3 = 1 + randomNumbers.nextInt( NumberRoll );
System.out.printf( "%d\n", face3 );
face4 = 1 + randomNumbers.nextInt( NumberRoll );
System.out.printf( "%d\n\n", face4 );
sum = face + face2;
sum2 = face3 + face4;
sum3 = Winner - Winner2;
sum4 = Winner2 - Winner;
sum5 = Winner + Winner2;
if ( sum == sum2 )
{
Ties = Ties + 1;
}
if ( sum2 > sum )
{
Winner2 = Winner2 + 1;
}
if ( sum > sum2 )
{
Winner = Winner + 1;
}
if ( sum == 1 )
{
sum = face + face2 * 2;
}
if ( sum == 1 )
System.out.printf( "%s, has rolled a lucky number, now %d multiplies by two!\n", Name, sum );
if ( sum == 62 )
sum = face2 + face2 * 2;
if ( sum == 62 )
System.out.printf( "%s, has rolled a lucky number, now %d multiplies by two!\n", Name, sum );
if ( sum2 == 17 )
sum2 = face3 + face4 * 2;
if ( sum2 == 17 )
System.out.printf( "%s, has rolled a lucky number, now %d multiplies by two!\n", Name2, sum2 );
if ( sum2 == 85 )
sum2 = face3 + face4 * 2;
if ( sum2 == 85 )
System.out.printf( "%s, has rolled a lucky number, now %d multiplies by two!\n", Name2, sum2 );
System.out.printf( "The sum for %s is %d\n", Name, sum );
System.out.printf( "The sum for %s is %d\n", Name2, sum2 );
if ( sum > sum2 )
System.out.printf( "%s has won the game!\n", Name );
if ( sum2 > sum )
System.out.printf( "%s has won the game!\n\n", Name2 );
if ( sum == sum2 )
System.out.println( "Tie!" );
if ( face == face2 )
System.out.printf( "%s has rolled the same two numbers, %d, and %d,\n The chances of doing that are %d to 1!\n", Name, face, face2, NumberRoll);
if ( face3 == face4 )
System.out.printf( "%s has rolled the same two numbers, %d, and %d,\n The chances of doing that are %d to 1!\n\n", Name2, face3, face4, NumberRoll );
if ( sum > sum2 )
System.out.printf( "Congradulations %s, you have won a game of Big Dice!\n\n", Name );
if ( sum < sum2 )
System.out.printf( "Congradulations %s, you have won a game of Big Dice!\n\n", Name2 );
System.out.printf( "Enter 1 if you would like to play again, enter 2 if you want to quit:\n" );
Go = input.nextInt ();
Games = Games + 1;
if ( Go == 2 )
System.out.printf( "\nYou have played %s Games of Big Dice!", Games );
if ( Go == 2 )
System.out.printf( "\n\n%s has won %d games of Big Dice!\n", Name, Winner );
if ( Go == 2 )
System.out.printf( "%s has won %s games of Big Dice!\n", Name2, Winner2 );
if ( Go == 2 )
if ( Ties < 1 )
System.out.printf( "%s has Tied %s %d times!\n", Name, Name2, Ties );
if ( Ties == 1 )
System.out.printf( "%s has Tied %s %d time!\n", Name, Name2, Ties );
if ( Go == 2 )
System.out.printf( "" );
if ( Go == 2 )
System.out.printf( "" );
if ( Winner > Winner2 )
System.out.printf( "\n%s has won %d more games than %s!\n ", Name, sum3, Name2 );
if ( Go == 2 )
System.out.println( "" );
if ( Winner2 > Winner )
System.out.printf( "\n%s has won %d more games than %s!\n ", Name2, sum4, Name );
if ( Go == 2 )
System.out.println( "" );
if ( Winner == Winner2 )
System.out.printf( "Tie!" );
}
if ( NumberRoll != 0 )
{
System.out.println( "" );
}
else
if ( counter % 5 == 0 )
System.out.println();
}
}
}
[Compiler]
Welcome to a game of Big Dice!
Have Fun!
Player1 please enter your first name:
Jerry
Please enter your first name Player2:
CPU
Whats the highest number you want your dice to roll(or 926620 for rules):
50
Jerry's Rolls
4
25
CPU's Rolls
9
4
The sum for Jerry is 29
The sum for CPU is 13
Jerry has won the game!
Congradulations Jerry, you have won a game of Big Dice!
Enter 1 if you would like to play again, enter 2 if you want to quit:
1
Welcome back Jerry, and, CPU!
Have Fun!
Whats the highest number you want your dice to roll:
50
Jerry's Rolls
36
19
CPU's Rolls
14
32
The sum for Jerry is 55
The sum for CPU is 46
Jerry has won the game!
Congradulations Jerry, you have won a game of Big Dice!
Enter 1 if you would like to play again, enter 2 if you want to quit:
1
Jerry has won 1 more games than CPU!
Welcome back Jerry, and, CPU!
Have Fun!
Whats the highest number you want your dice to roll:
50
Jerry's Rolls
12
2
CPU's Rolls
47
6
The sum for Jerry is 14
The sum for CPU is 53
CPU has won the game!
Congradulations CPU, you have won a game of Big Dice!
Enter 1 if you would like to play again, enter 2 if you want to quit:
2
You have played 3 Games of Big Dice!
Jerry has won 2 games of Big Dice!
CPU has won 1 games of Big Dice!
Jerry has Tied CPU 0 times!
Jerry has won 2 more games than CPU!
[Compiler]

