Write a program that creates a two-dimensional array named height and stores the following data:
16 17 14
17 18 17
15 17 14
The program should also print the array.
Expected Output
[[16, 17, 14], [17, 18, 17], [15, 17, 14]]
Can anybody help me with this
Answers
Answered by
0
Answer:
Program:-
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int height[][]=new int[3][3];
System.out.println("Enter the elements of the array");
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
height[i][j]=in.nextInt();
}
System.out.println();
}
System.out.println("Given Array:");
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
System.out.print(height[i][j]+ " ");
}
System.out.println();
}
System.out.println("The Array in the given format:"); System.out.println(Arrays. deepToString(height));
}
}
- Output is attached
Attachments:
![](https://hi-static.z-dn.net/files/dff/3f5f068b29b37fdeb2c064afd272afb0.jpg)
Similar questions
Chemistry,
2 months ago
Accountancy,
2 months ago
Math,
2 months ago
Social Sciences,
4 months ago
Math,
4 months ago
Biology,
11 months ago
Math,
11 months ago