can this be answered in java please 12.3 1.7 3.2 -4.1 2.73 8.75 6.3 11.0 9.14 4.
ID: 3777935 • Letter: C
Question
can this be answered in java please 12.3
1.7
3.2
-4.1
2.73
8.75
6.3
11.0
9.14
4.374
2.24
7.6
3.12
Array dNums
Write a statement to populate the two-dimensional array dNums with the values above using shortcut notation.
Display the value stored in dNums[0][0].
Display the values stored in dNums[1][2].
Increase the value stored in each element in the last row by 20%. Use a for loop to traverse the row. Use another for loop to display the updated values.
Write a for block that displays each value in the third column, one value per line.
Write a block of code that uses nested for loops to sum all array values to the accumulator variable dGrand.
Methods
Write a method header for a void method named fvFindHigh that receives the array iNums1 as a parameter.
Write a statement that populates a two-dimensional array named iNums2 as follows using shortcut notation:
Write a method header for a void method named fvFindLow that receives the array iNums2 as a parameter.
Write a method named fvPop that receives the empty array iNums3 as a parameter. Assume iNums3 was declared as int iNums3[][] = new int[3][3]. In the method, populate it with end-user input using a dialog to prompt the user for each value. Construct your input dialog and programming logic so it works like this. Apply an adjustment for zero-based addressing.
Row 1 Value 1: 4
Row 1 Value 2: 13
Row 1 Value 3: 9
Row 2 Value 1: 2
Row 2 Value 2: 1
Row 2 Value 3: 6
Row 3 Value 1: 31
Row 3 Value 2: 8
Row 3 Value 3: 51
1.7
3.2
-4.1
2.73
8.75
6.3
11.0
9.14
4.374
2.24
7.6
3.12
Explanation / Answer
import java.util.*;
public class ArrayManipulations{
void fvFindHigh(double[] iNums1);
void fvFindHigh(double[][] iNums2);
int[][] fvPop(int[][] iNums3){
Scanner sc = new Scanner(System.in);
for (int i=0; i<3; i++){
for (int j=0; j<3; j++){
System.out.print("Row " + (i+1) + " Value " + (j+1) + ": ");
iNums3[i][j] = sc.nextInt();
System.out.print(" ");
}
}
sc.close();
return iNums3;
}
public static void main(String[] args) {
double[][] dNums = {{1.7, 3.2, -4.1, 2.73}, {8.75, 6.3, 11.0, 9.14}, {4.374, 2.24, 7.6, 3.12}};
System.out.println("dNums[0][0] = " + dNums[0][0]);
System.out.println("dNums[1][2] = " + dNums[1][2]);
for (int i = 0; i<3; i++){
dNums[2][i] *= 1.2;
}
for (int i = 0; i<3; i++){
System.out.println("dNumbs[2][" + i + "] = " + dNums[2][i]);
}
for (int i = 0; i<3; i++){
System.out.println("dNumbs[" + i + "][2] = " + dNums[i][2]);
}
double dGrand = 0;
for (int i=0; i<3; i++){
for(int j=0; j<3; j++){
dGrand += dNums[i][j];
}
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.