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

Given a two-dimensional array named scores with double type elements, write the

ID: 3703094 • Letter: G

Question

Given a two-dimensional array named scores with double type elements, write the embedded loop to navigate this array and multiply each element in the array by 10, and put the embedded loop inside a method named increase , and the only parameter of this method is a double type two-dimensional array. This method increase should have void as its return type.

Write the one line of code to invoke the increase method inside main. Do you need to receive the return value of increase with a local variable, why or why not?

Given a two-dimensional array named scores with double type elements, write the embedded loop to navigate this array and summarize all items in this array, and put the embedded loop inside a method named sum , and the only parameter of this method is a double type two-dimensional array. This method sum should return the summarized total, therefor its return type should be double.

Write the one line of code to invoke the sum method inside main, and receive the return value with a local variable. What type should this local variable be? Then use a second line of code to output the return value to the console. Assume the actual parameter (the double type two-dimensional array) you plug in for method increase has been initialized.

Explanation / Answer

Question 1

Answer:

public void increase(double scores[][]) {
for(int i=0;i<scores.length;i++) {
for(int j=0;j<scores[i].length;j++) {
scores[i][j]=scores[i][j] * 10;
}
}
}

Question 2

Answer:

increase (scores);

We do not need to receive the return vvalue of increse as it is void type it will not return any value.

Question 3

Answer:

public double sum (double scores[][]) {
double total = 0;
for(int i=0;i<scores.length;i++) {
for(int j=0;j<scores[i].length;j++) {
total+=scores[i][j];
}
}
return total;
}

Question 4

Answer:

double total = sum (scores);

System.out.println(total);

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