# Answer to Question #16116 in Java | JSP | JSF for jessan

Question #16116

Can you guys plss help me on this problem,..I nid it A.S.A.P.

2.1.Make a program that allows you to create a 3 X 4 integer array. Your program will initialize the array with random numbers from 0 to 1000. Your program also will identify and display the largest value, smallest value, sum and average value of all data in the array.

2.1.Make a program that allows you to create a 3 X 4 integer array. Your program will initialize the array with random numbers from 0 to 1000. Your program also will identify and display the largest value, smallest value, sum and average value of all data in the array.

Expert's answer

import java.util.Random;

public class main {

/**

* @param

args

*/

public static void main(String[] args)

{

int[][] arr=new

int[3][4];

Random ran=new Random();

for (int i = 0; i < arr.length;

i++)

{

for (int j = 0; j < arr[0].length; j++)

{

arr[i][j]=ran.nextInt(1001);

}

}

int max=arr[0][0];

int

min=arr[0][0];

int sum=0;

int ave;

for (int i = 0; i < arr.length;

i++)

{

for (int j = 0; j < arr.length; j++)

{

if(arr[i][j]>max)

{

max=arr[i][j];

}

if(arr[i][j]<min)

{

min=arr[i][j];

}

sum+=arr[i][j];

}

}

ave=sum/(arr.length*arr[0].length);

System.out.println("largest

value "+max);

System.out.println("smallest value

"+min);

System.out.println("sum "+sum);

System.out.println("average value

"+ave);

}

}

public class main {

/**

* @param

args

*/

public static void main(String[] args)

{

int[][] arr=new

int[3][4];

Random ran=new Random();

for (int i = 0; i < arr.length;

i++)

{

for (int j = 0; j < arr[0].length; j++)

{

arr[i][j]=ran.nextInt(1001);

}

}

int max=arr[0][0];

int

min=arr[0][0];

int sum=0;

int ave;

for (int i = 0; i < arr.length;

i++)

{

for (int j = 0; j < arr.length; j++)

{

if(arr[i][j]>max)

{

max=arr[i][j];

}

if(arr[i][j]<min)

{

min=arr[i][j];

}

sum+=arr[i][j];

}

}

ave=sum/(arr.length*arr[0].length);

System.out.println("largest

value "+max);

System.out.println("smallest value

"+min);

System.out.println("sum "+sum);

System.out.println("average value

"+ave);

}

}

## Comments

## Leave a comment