You are on page 1of 1

import java.util.

Scanner;
public class Testule
{ //calculate average
public static void main(String args[]) {
int i;
System.out.println("Enter number of subjects");
Scanner sc=new Scanner(System.in);

int n=sc.nextInt();
int[] a=new int[n];
double avg=0;

System.out.println("Enter marks");

for( i=0;i<n;i++)
{
a[i]=sc.nextInt();
}
for( i=0;i<n;i++)
{
avg=avg+a[i];
}
System.out.print("Average of (");

for(i=0;i<n-1;i++)
{
System.out.print(a[i]+",");
}
System.out.println(a[i]+") ="+avg/n);

}
}

This study source was downloaded by 100000779372287 from CourseHero.com on 03-19-2024 02:31:16 GMT -05:00

https://www.coursehero.com/file/75383471/CalculateAvetxt/
Powered by TCPDF (www.tcpdf.org)

You might also like