subject

I am in an Intro to Java class. We were instructed to create a code using multidimensional arrays that would produce the output: [5, 6, 7, 8]
[
[2, 4, 6, 8]
[8, 7, 9, 1]
[3, 5, 1, 2]
]

[
[1, 2]
[3, 4, 5]
[6]
[7, 8, 9]
]

I’ve been working on it, but have gotten stuck. If anyone could finish my code, and point out where I’m going wrong, I would greatly appreciate it. Here’s my code:

public class ArrayPrinter{

public static void main(String[]args) {
int[] oneD = {5, 6, 7, 8};
printArray(oneD);
System. out. println();
int[][] twoD = {{2, 4, 6, 8},
{8, 7, 9, 1},
{3, 5, 1, 2}};
printArray(twoD);
System. out. println();
int[][] twoD2 = {{1, 2},
{3, 4, 5},
{6},
{7, 8, 9}};
printArray(twoD2);

}

public static void printArray(int[] arr) {
System. out. print("[");
for(int i = 0; i < arr. length; i++) {
System. out. print(arr. length);
if(i < arr. length -1) {
System. out. print(" ");
}}

}
public static void printArray (int[][] arr) {
for (int i=0; i < arr. length; i++) {
System. out. print(arr[i] + " ");
}
}
public static void printArray(int[][][] arr) {

System. out. println(" ");

System. out. println("]");
printArray(arr[i]);

System. out. println("]");

System. out. println("]");
}}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 00:30
Jenny wants to look at row 345 and compare it to row 17. what can she do if she wanted to easily adjust to see both at once?
Answers: 3
question
Computers and Technology, 22.06.2019 06:30
Exchanging which type of data uses the least bandwidth? music photographs video voice bandwidth- the amount of data that can be moved between two points in a set time period
Answers: 1
question
Computers and Technology, 22.06.2019 23:50
You need to design a circuit that implements the functions in the following table: s0 s1 function0 0 a + 10 1 a – b1 0 a + b1 1 a – 1s0 and s1 are 1-bit control inputs to select the function of the circuit. inputs a and b are 4-bitnumbers in 2s complement form. the output is also a 4-bit number in 2s complement form.you are allowed to use only one ttl 7483 4-bit adder to implement all the functions. but anynumber of other components (except the adder) can be used.hint: design a combinational logic circuit to modify the input b and the “carry input” of theadder depending on the control inputs s0 and s1.important: lab grade will depend on the working of the circuit & will be checked of by your labinstructor.1. is the output valid for the following input combinations: a. s0 = 0, s1 = 0, a = 7, b = 3? b. s0 = 0, s1 = 1, a = 7, b = 3? c. s0 = 1, s1 = 0, a = -4, b = -5? d. s0 = 1, s1 = 1, a = -8, b = 6? 2. what is the range of inputs (for both a and b) that will produce the valid output for all the functions?
Answers: 3
question
Computers and Technology, 24.06.2019 16:00
To fill (copy) a cell across or down, point to the of the cell and drag. top left corner top right corner bottom left corner bottom right corner
Answers: 3
You know the right answer?
I am in an Intro to Java class. We were instructed to create a code using multidimensional arrays th...
Questions
question
Biology, 25.03.2020 22:52
Questions on the website: 13722367