Question: import java.util.*; 2 3 class PrintHelper extends Object 4 { 5 public double[] getTemperatures() 6 { 7 double[] temps = new double[7]; temps[0] = 5.6;
import java.util.*; 2 3 class PrintHelper extends Object 4 { 5 public double[] getTemperatures() 6 { 7 double[] temps = new double[7]; temps[0] = 5.6; temps[1] = 2; 8 9 for( int i = 2; i < temps.length ; i++) 10 { 11 temps[i] = (i + 1) * 3 + 17; 12 } 13 14 return temps; 15 } 16 17 public void PrintArray( double[] temps ) 18 { 19 // print out all the elements of the array that will be passed to this method 20 // by looping through a counter, incrementing against the array length, then 21 // printing out the array 22 } 23 24 public double[] ClonePlusTwo( double[] array ) // <-- This method RETURNS a value (a double) ######### 25 { 26 // create a newArray, each element is 2 higher than the original, all done 27 // by looping through, incrementing a count according to length of array 28 // then adding 2 to the elements of array to create the lements of the newArray 29 30 // return newArray; 31 } 32 33 public void UpByTwo( double[] array ) // <-- This method does NOT return a value ######## 34 { 35 // This method will be given an array. The method will then increase 36 // value of each element of that array by two. 37 } 38 } 39 40 public class ParamReturnValuePractice extends Object 41 { 42 public static void main(String[] args) 43 { 44 PrintHelper ph = new PrintHelper(); 45 46 double[] temperatures; 47 temperatures = ph.getTemperatures(); 48 // ph.PrintArray( temperatures ); 49 // ph.UpByTwo( temperatures ); 50 // ph.PrintArray( temperatures ); 51 // double[] clone2 = ph.ClonePlusTwo( temperatures ); 52 // ph.PrintArray( clone2 ); 53 } 54 }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
