Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This skeleton code will be utilized to program out the required methods in Eclipse. The code comes with a tester class with main in order

image text in transcribedimage text in transcribedimage text in transcribed

This skeleton code will be utilized to program out the required methods in Eclipse. The code comes with a tester class with main in order to test the methods you are required to implement.

public class Trail { private int[] markers; public Trail(int[] elevation) { markers = elevation; } // Solution to Part A. public boolean isLevelTrailSegment(int start, int end) {

}

//Solution to Part B public boolean isDifficult() {

} public static void main(String[] args) { int[] elevation = {100, 150, 105, 120, 90, 80, 50, 75, 75, 70, 80, 90, 100}; Trail thisTrail = new Trail(elevation); //Exam's test case between index 7 and 10 if (thisTrail.isLevelTrailSegment(7,10)) System.out.println("This part of the trail is level."); //Test case between index 7 and 11 if (!thisTrail.isLevelTrailSegment(7,11)) System.out.println("But adding segment 11 makes it not level."); // This is their test again. if (thisTrail.isDifficult()) System.out.println("The int[] elevation Array is difficult."); //Test a trail that is not difficult int[] easyTrail = {90, 110, 81, 51, 80, 110, 139, 120, 100}; Trail easy = new Trail(easyTrail); if (!easy.isDifficult()) System.out.println("And int[] easyTrail Array is easy!"); } }

1. A statistician is studying sequences of numbers obtained by repeatedly tossing a six-sided number cube. On each side of the number cube is a single number in the range of 1 to 6, inclusive, and no number is repeated on the cube. The statistician is particularly interested in runs of numbers. A run occurs when two or more consecutive tosses of the cube produce the same value. For example, in the following sequence of cube tosses, there are runs starting at positions 1, 6, 12, and 14 Index 0 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 Result 5543122226133555 5 The number cube is represented by the following class. public class NumberCube /** @return an integer value between 1 and 6, inclusive public int toss // There may be instance variables, constructors, and methods that are not shown implementation not shown / You will implement a method that collects the results of several tosses of a number cube and another method that calculates the longest run found in a sequence of tosses. (a) Write the method getCubeTosses that takes a number cube and a number of tosses as parameters. The method should return an array of the values produced by tossing the number cube the given number of times. Complete method getCubeTosses below Returns an array of the values obtained by tossing a number cube numTosses times. * @param cube a NumberCube *@param numTosses the number of tosses to be recorded /** Precondition: numTosses >0 *@return an array of numTosses values public static int[] getCubeTosses (NumberCube cube, int numTosses)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

List some of the drivers for RDW.

Answered: 1 week ago