Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in Java and run it in BlueJ according to the following specifica

ID: 3717956 • Letter: W

Question

Write a program in Java and run it in BlueJ according to the following specifications:

The program reads a text file with student records (first name, last name and grade) and prints them in the terminal window.

After the name and grade it also prints the type of the grade: excellent (> 89), ok [60,89], and failure (< 60).

Then the program prints the number of students, and their average grade and also the number of students and their average in each grade category (excellent, ok, and failure).

The program also prints the student with the highest and the student with the lowest grade.

Explanation / Answer

import java.io.*;

import java.util.*;

public class Chegg5 {

public static void main(String[] args) {
try{

File file = new File("Tester.java");

Scanner sc = new Scanner(file);

int totalSum=0,totalCount=0;

int excellentSum=0,excellentCount=0;

int okSum=0,okCount=0;

int failureSum=0,failureCount=0;

while (sc.hasNextLine()){

String temp[]=sc.nextLine().split("(?<=\D)(?=\d)|(?<=\d)(?=\D)");

int marks=Integer.parseInt(temp[1]);

totalSum+=marks;totalCount++;

if(marks>89) {excellentSum+=marks;excellentCount++;}

else if(marks>=60 && marks<=89) {okSum+=marks;okCount++;}

else if(marks<60) {failureSum+=marks;failureCount++;}

}

System.out.println("There are "+totalCount+" students with average grade "+(float)totalSum/totalCount);

System.out.println("There are "+excellentCount+" excellent students with average grade "+(float)excellentSum/excellentCount);

System.out.println("There are "+okCount+" ok students with average grade "+(float)okSum/okCount);

System.out.println("There are "+failureCount+" failre students with average grade "+(float)failureSum/failureCount);
}catch(Exception e){System.out.println("File not found check once and try again");}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote