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:
Similar questions
Math,
1 month ago
India Languages,
1 month ago
Social Sciences,
3 months ago
Math,
3 months ago
Biology,
10 months ago
Math,
10 months ago