Computer Science, asked by robertweber, 3 months ago

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 kamalrajatjoshi94
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