HELP Im not really good at Java PLEASE Example im so lost im

 HELP! I\'m not really good at Java!!! PLEASE Example, i\'m so lost.  import java.util.Random; import java.util.Scanner;  /**  * Find the longest run in a sequence of die tosses.  *   * This is a possible solution to Programming Exercise P6.13  *   * \"Write a program that generates a sequence of 20 random die tosses in an   * array and that prints the die values, marking only the longest run,   * like this:  *   1 2 5 5 3 1 2 4 3 (2 2 2 2) 3 6 5 5 6 3 1  *   * If there is more than one run of maximum length, mark the first one.\"  */ public class FindLongestRunLab {      public static void main(String[] args) {          //        int[] sequence = {1, 2, 5, 5, 3, 1, 2, 4, 3, 2, 2, 2, 2, 3, 6, 5,  //                5, 6, 3, 1};         Random rng = new Random();                 Scanner inp = new Scanner(System.in);                  while(true) {             System.out.print(\"Enter the number of die tosses: \");             int numTosses = inp.nextInt();             if(numTosses <= 0) {                 break;             } //          int[] sequence = {1, 2, 5, 5, 3, 1, 2, 4, 3, 2, 2, 2, 2, 3, 6, 5,  //                5, 6, 3, 1};              int[] sequence = generateRandomDieTosses(numTosses, rng);             int runStart = findLongestRun(sequence, sequence.length);             int runLen = findRunLength(sequence, sequence.length, runStart);                     int runEnd = runStart + runLen - 1;             printSequenceAndMarkRun(sequence, runStart, runEnd);         }     }      /**      * Print the sequence of integers and mark the run with ()      *       * @param sequence     sequence of integers      * @param runStart     index for the start of run      * @param runEnd       index for the end of run.      */     private static void printSequenceAndMarkRun(int[] sequence, int runStart,              int runEnd) {         //TODO implement method body     }          /**      * Returns the starting index of the longest run in a sequence of integers.      *       * @param data          sequence of integers      * @param numData       sequence length      * @return starting index of longest run.      */     private static int findLongestRun(int[] data, int numData) {         // TODO implement method body        return 0;     }          /**      * returns the length of a run in a sequence of integers      *       * @param data              sequence of integers      * @param numData           sequence length      * @param runStartIdx       starting index of the run      * @return  length of run      */     private static int findRunLength(int[] data, int numData, int runStartIdx) {         // TODO implement method body         return 0;     }          /**      * Generate a sequence of random die tosses.  An die has 6 sides that are       * labeled 1, 2, 3, 4, 5, 6.      *       * @param numDieTosses number of die tosses to simulate      * @param rng          Random Number Generator      * @return array that contains the die tosses.      */     private static int[] generateRandomDieTosses(int numDieTosses,              Random rng) {                  int[] dieTosses = new int[numDieTosses];                  for(int k = 0; k < numDieTosses; ++k) {             dieTosses[k] = rng.nextInt(6) + 1;         }                  return dieTosses;     } } 

Solution

import java.util.Random;

public class Run

{

    public static void main(String args[])

    {

        int[] dices = new int[21];

        String str = \"\";

        Random rand = new Random();

        boolean inRun = false;

        for (int i = 0;i<20;i++)

        {

            dices[i] = rand.nextInt(6)+1;

        }

        for (int i =0;i<20;i++)

        {

                str = str +dices[i];

        }

        System.out.println(str);

       

        int count = 0;

        int maxcount = 0;

        int endPosition= 0;

        boolean inMax = false;

        for (int i = 0;i<20;i++)

        {

            if (dices[i]==dices[i+1])

            {

                count++;

                if(count >= maxcount)

                {

                    maxcount = count+1;

                    inMax = true;

                }

            }

            if (dices[i]!=dices[i+1])

            {

                if(inMax)

                {

                    endPosition = i;

                    inMax = false;

                }

                count=0;

               

          }

        }

        int startPosition= endPosition - maxcount+1;

        System.out.println(str.substring(0,startPosition)+\"(\"+str.substring(startPosition,endPosition+1)+\")\"+str.substring(endPosition+1,20));

       

    }

}

 HELP! I\'m not really good at Java!!! PLEASE Example, i\'m so lost. import java.util.Random; import java.util.Scanner; /** * Find the longest run in a sequence
 HELP! I\'m not really good at Java!!! PLEASE Example, i\'m so lost. import java.util.Random; import java.util.Scanner; /** * Find the longest run in a sequence

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site