import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
System.out.println("Enter numbers of marks: ");
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
double [] marks = new double[n];
System.out.printf("Enter %d marks: ", n);
for(int i=0; i<n; i++){
marks[i] = scan.nextDouble();
}
double max = marks[0];
double min = marks[0];
double sum = 0;
int k=0;
for(int i=0; i<n; i++){
sum += marks[i];
if (marks[i]>max){
max = marks[i];
}
if (marks[k]<max){
min = marks[i];
}
k++;
}
double average = sum / n;
System.out.println("Highest Mark= "+max+"%");
System.out.println("Lowest Mark= "+min+"%");
System.out.println("Average= "+average+"%");
}
}
Comments
Leave a comment