Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. (10 points; 2 points each) You have an array of earthquake data for Oklahoma

ID: 3698600 • Letter: 2

Question

2. (10 points; 2 points each) You have an array of earthquake data for Oklahoma for the last year doublel] richterValues; I/ constructed and initialized elsewhere as a Perfect Size Array Use the methods in the Arrays API to do the following actions. Note: Each of these items is a single line of code that will call one method in the Arrays class. No credit will be given for writing the logic to do this work instead of using the Arrays class method a) Sort the values in the richterValues array b) Store a String representation of the richterValues values into a new String called summary. (Note: For this and the remaining questions, you will need to declare the new variable to catch the results of the method call) c) Make a new copy of the first 5 items in the array. Store this array in a new double array called five. (Note: If there are less than 5 items in the richterValues array, leave the new values added as 0.) d) Check to see if the richterValues array is equal to the double array named ray (assume the ray array has been declared and initialized for your already) and store that value into a new boolean variable called isSame, e) Make a new copy richterValues array that contains only the items in index 3-index 7, inclusive. Store this array in a new double array called newbie. (Note: In this case, you may assume that the value in index 3. Inclusive means that the items at index 3 and index 7 are both included in the final array.) array has at least 4 items so there is definitelya

Explanation / Answer

a)

double richterValues[]= {23,45.56,34,57};

b)

String summary=Arrays.toString(richterValues);

c)
double five[]=Arrays.copyOf(richterValues, 5);

d)

boolean isSame = Arrays.equals(richterValues, ray);

e)

double[] newbie=Arrays.copyOfRange(richterValues, 3, 7);

//Please do let me know if u have any concern...

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote