98 867
Assignments Done
98.6%
Successfully Done
In April 2021

# 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.
1
2012-10-08T11:17:13-0400
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);

}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!