Finish the code below, writing the 3-deep nested loop needed to set all of the v
ID: 3808306 • Letter: F
Question
Finish the code below, writing the 3-deep nested loop needed to set all of the values in arr to 1.5//Lab 8c////// public class Lab8c {public static void main(String[] args) {int SIZE = Integer.parselnt(args[0]);//Create a 3-dimensional array of double where//the size of each dimension is SIZE: double table[][][] =//[add code here];//Fill in the table using a 3-deep nested loop so that//table[a][b][c] = 1.5 for all a,b,c//[add code herel}} Make sure that your code compiles and runs with a size value of 10. Re-run the program, increasing the SIZE value until you find the largest value you can use without getting an OutOfMemory error. Write the largest size value that worked for you in a comment at the top of Lab8c.java.Explanation / Answer
import java.util.*;
public class Lab8{
public static void main(String args[]){
int SIZE = Integer.parseInt(args[0]);
double[][][] table= new double[SIZE][SIZE][SIZE];
for(int i=0;i<SIZE;i++){
for(int j=0;j<SIZE;j++){
for(int k=0;k<SIZE;k++){
table[k][j][i] = 1.5;
}
}
}
for(int i=0;i<SIZE;i++){
for(int j=0;j<SIZE;j++){
for(int k=0;k<SIZE;k++){
System.out.print(table[k][j][i]+" ");
} System.out.println();
} System.out.println(); }
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.