Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1: Filling An Array With User Input: Processing All Elements Of An Array Check ParamReturnValuePractice.java code, and fill in the ??? with return value

Part 1: Filling An Array With User Input: Processing All Elements Of An Array

Check ParamReturnValuePractice.java code, and fill in the ??? with return value & parameters for each of the given methods.Only AFTER you've set up return values & parameters for ALL the methods should you go back & start filling them in.Then uncomment the code in the main method and test your work by running the program. Explain (using comments in the code) why you made the choices you did, and why those choices are better than any alternatives.

Part 2: Practice Using Arrays: Processing All Elements Of An Array

Continue using the ParamReturnValuePractice.java code. At the end of the main method, create array of doubles that has space enough for five separate values.Write while loop that will set the value of the first 5 elements of your array to the numbers 6 through 10.Then write for loop that will print out the first 5 elements of your array.

class PrintHelper extends Object

{

public double[] getTemperatures()

{

double[] temps = new double[7]; temps[0] = 5.6; temps[1] = 2;

for( int i = 2; i < temps.length ; i++)

temps[i] = (i + 1) * 3 + 17;

return temps;

}

public ??? printArray( ??? )

{

// // print out all the elements of the array that will be passed

// // to this method.

// // This method (and all the others) should be able operate on the

// // array that getTemperatures produces

}

public ??? averageArray( ??? )

{

// total up the array, then return the average

}

public ??? clonePlusTwo( ??? )

{

// create new array, each element is 2 higher than the original

}

public ??? upByTwo( ??? )

{

// This method will be given an array.The method will then increase

// the value of each element of that array by two.

}

}

public class ParamReturnValuePractice extends Object

{

public static void main(String[] args)

{

PrintHelper ph = new PrintHelper();

double[] ts = new double[3];

// ts = ph.getTemperatures();

System.out.println("Temperatures:");

// ph.printArray( ts );

// ph.upByTwo( ts );

System.out.println("New Temperatures:");

//ph.printArray( ts );

// double[] clone2 = ph.clonePlusTwo( ts );

// ts[0] = 88;

System.out.println("Cloned Temperatures");

// ph.printArray( clone2 );

// System.out.println("Average of Cloned Temperatures"+ averageArray(clone2));

}

}

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Programming questions

Question

The emancipation proclamation issued?

Answered: 1 week ago