Write a java code for the following Upload the java code Inp

Write a java code for the following. (Upload the java code) Input 7 numbers in an array. (Use Scanner for user input) Print all the values in the array. Compute the maximum and minimum in the array. Compute the average of 7 numbers.

Solution

import java.io.IOException;

import java.util.Scanner;

public class Main {

public static void main(String args[]) throws IOException {

Scanner sc = new Scanner(System.in);

int[] array = new int[7];

int sum = 0;

int min = Integer.MAX_VALUE,max = Integer.MIN_VALUE;

for(int i = 0; i < 7; i++)

{

   array[i] = sc.nextInt();

   sum += array[i];

   if(array[i] < min)

       min = array[i];

   if(array[i] > max)

       max = array[i];

}

System.out.println(\"Min: \" + min);

System.out.println(\"Max: \" + max);

System.out.println(\"Average: \" + sum/7.0);

sc.close();

}

}

 Write a java code for the following. (Upload the java code) Input 7 numbers in an array. (Use Scanner for user input) Print all the values in the array. Comput

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site