Question: A run is a sequence of adjacent repeated values. Write a program that prompts the user to enter a sequence length n, then creates an

A run is a sequence of adjacent repeated values. Write a program that prompts the user to enter a sequence length n, then creates an object to generate a sequence of n random die tosses in an array and a method to print the die values, marking runs by including them in parentheses, like this:

1 2 (5 5) 3 1 2 4 3 (2 2 2 2) 3 6 (5 5) 6 3 1

Use the following pseudocode:

Set a boolean value inRun to false. For each index i in the array { If inRun { if(values[i] is different from the preceding value{ print ) inRun = false } } if not inRun { if values[i] is the same as the following value{ print ( inRun = true } } print values[i] } If inRun, print )

How would I fix my code I am so lost.

My code:

import java.util.Scanner;

import java.util.Random;

public class InRun {

boolean inRun; int n; //variable for sequenceLength int i; //variable for index of array float[] array = new float[n]; public InRun(int sequenceLength) { sequenceLength = n; this.inRun = false; } public String getValue(){ if(array[i] != i) { inRun = false; } else(float[i] == i) { inRun = true; } return array[i]; }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!