Write a program to store 8 numbers in an array and display their sum and average
Answers
Answered by
1
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
Similar questions