d "main" java.l

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Hi, can you please help me debug my program? I need it to stimulate dices rolling but I am getting errors:  
 
Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
Syntax error, insert "else Statement" to complete IfStatement
Syntax error, insert "else Statement" to complete IfStatement
Syntax error, insert "}" to complete Block
Syntax error, insert "}" to complete Block
Syntax error, insert "}" to complete MethodBody
 
at DiceSimulation.main(DiceSimulation.java:108)
 
 
Here is my code:

import java.util.Random;   // Needed for the Random class

 

/**

   This class simulates rolling a pair of dice 10,000 times

   and counts the number of times doubles of are rolled for

   each different pair of doubles.

*/

 

public class DiceSimulation

{

   public static void main(String[] args)

   {

      final int NUMBER = 10000;  // Number of dice rolls

 

      // A random number generator used in

      // simulating the rolling of dice

      Random generator = new Random();

 

      int die1Value;       // Value of the first die

      int die2Value;       // Value of the second die

      int count = 0;       // Total number of dice rolls

      int snakeEyes = 0;   // Number of snake eyes rolls

      int twos = 0;        // Number of double two rolls

      int threes = 0;      // Number of double three rolls

      int fours = 0;       // Number of double four rolls

      int fives = 0;       // Number of double five rolls

      int sixes = 0;       // Number of double six rolls

      

      while(count < NUMBER)

     for (count = 0; count < NUMBER;)

      {

      die1Value = generator.nextInt(6)+1;

      die2Value = generator.nextInt(6)+1;

      

      count = snakeEyes;

    

       if (die1Value == die2Value);

      {

      if(die1Value == 1)

      {

      snakeEyes = 1;}

      else if (die1Value == 1)

      {

      snakeEyes = 2;}

      else if (die1Value == 2)

      {

      snakeEyes = 3;}

      else if (die1Value == 3) 

      {

      snakeEyes = 4;}

      else if (die1Value == 4) 

      {

      snakeEyes = 5;}

      else if (die1Value == 5) 

      {

      snakeEyes = 6;}

      else if (die1Value == 6)

    

      if (die2Value == die1Value)

      {

      count++;

      while(count < NUMBER)

      {

      if(die2Value == 1)

  {

  snakeEyes=1;}

  elseif(die2Value==1)

  {

  snakeEyes=2;}

  elseif(die2Value==2)

  {

  snakeEyes=3;}

  elseif(die2Value==3) 

  {

  snakeEyes=4;}

  elseif(die2Value==4) 

  {

  snakeEyes=5;}

  elseif(die2Value==5) 

  {

  snakeEyes=6;}

  elseif(die2Value==6) 

 

      {

      count++;

      }

      // Display the results

      System.out.println ("You rolled snake eyes " +

                          snakeEyes + " out of " +

                          count + " rolls.");

      System.out.println ("You rolled double twos " +

                          twos + " out of " + count +

                          " rolls.");

      System.out.println ("You rolled double threes " +

                          threes + " out of " + count +

                          " rolls.");

      System.out.println ("You rolled double fours " +

                          fours + " out of " + count +

                          " rolls.");

      System.out.println ("You rolled double fives " +

                          fives + " out of " + count +

                          " rolls.");

      System.out.println ("You rolled double sixes " +

                          sixes + " out of " + count +

                          " rolls.");

      }

 }

Expert Solution
steps

Step by step

Solved in 2 steps with 9 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY