Question
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
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.
import java.util.*;
public class NumberCube { Random r; public NumberCube() { r = new Random(); } public int toss() { return r.nextInt(6)+1; } // Solution to part (a) public static int[] getCubeTosses(NumberCube cube, int numTosses) { } // Solution to part (b) public static int getLongestRun(int[] values) { } // For testing purposes to display the random array created in part a public static void print(int[] vals) { for (int i=0; i System.out.print(vals[i]+" "); System.out.println(); } // Test these methods. public static void main(String[] args) { // Test for part (b) NumberCube myDie = new NumberCube(); int[] rolls = {1,5,5,4,3,1,2,2,2,2,6,1,3,3,5,5,5,5}; System.out.println("The longest run for the sample hardcoded into tester starts at index "+getLongestRun(rolls)); System.out.println(""); // Test for part (a) and (b) rolls = getCubeTosses(myDie, 40); print(rolls);//shows that random array created in part a System.out.println("The longest run for the random array above starts at index "+getLongestRun(rolls)); } }
3. A hiking trail has elevation markers posted at regular intervals along the trail. Elevation information about a trail can be stored in an array, where each element in the array represents the elevation at a marker. The elevation at the first marker will be stored at array index 0, the elevation at the second marker will be stored at array index 1, and so forth. Elevations between markers are ignored in this question. The graph below shows an example of trail elevations. TRAIL ELEVATION 160 2140 100 80 60 40 20 0 0 2 345 6 7 8 9 10 11 12 Index The table below contains the data represented in the graph Trail Elevation (meters) Index 02345678910 12 00 150 105 120 90 805075 7570 80 90 100 ElevationStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started