importjava.util.Scanner;classMain{publicstaticvoidmain(String[]args){Scannerscanner=newScanner(System.in);System.out.println("Enter number of grades:");intnrOfGrades=scanner.nextInt();doublegradeSum=0.0;intnrOfDistinctions=0;intnrOfPass=0;intnrOfFails=0;for(inti=1;i<(nrOfGrades+1);i++){System.out.println("Enter grade "+i+":");intnextGrade=scanner.nextInt();if(nextGrade>=75){nrOfDistinctions++;}elseif(nextGrade>=40){nrOfPass++;}else{nrOfFails++;}gradeSum=gradeSum+nextGrade;}System.out.println();System.out.println("Summary:");System.out.println(nrOfDistinctions+" in Distinction");System.out.println(nrOfPass+" in Pass");System.out.println(nrOfFails+" in Fail");System.out.println();System.out.println("Average grade: "+(gradeSum/nrOfGrades));}}