Write a program to store 8 numbers in an array and display their sum and average
Share
Write a program to store 8 numbers in an array and display their sum and average
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Answer:
import java.util.Scanner;
public class Brainly
{
public static void main (String args[])
{
Scanner sc= new Scanner(System.in);
int a,b,c,d,e,f,g,h,sum;
double avg;
System.out.println("Enter 8 numbers");
a= sc.nextInt();
b= sc.nextInt();
c= sc.nextInt();
d= sc.nextInt();
e= sc.nextInt();
f= sc.nextInt();
g= sc.nextInt();
h= sc.nextInt();
sum= a+b+c+d+e+f+g+h;
System.out.println("The sum of numbers"+sum);
avg=sum/8.0;
System.out.println("The average of numbers"+avg);
}
}
I have used the scanner class in java programming language..
please mark my answer as brainliest