Question Answered step-by-step Hello. tutors. Based on this information, could you check my code?… Hello. tutors. Based on this information, could you check my code? i’ve made my code. but it’s not working. and I don’t know what’s the problem it is. we don’t need to use arrays or arraylists. Image transcription textWrite a program to read in a list ofnames and grades from a ?le. Find theaverage score and print o… Show more… Show more This is the output sample: This is my code: public class PracticeQuestionP2 { public static void main (String [] args) throws IOException{ { Scanner input = new Scanner(System.in); System.out.print(“Enter the input filename: “); String fileName = input.nextLine(); File file = new File(fileName); Scanner fileIn = new Scanner(file); String firstName, lastName; double scores; int count = 0; double sum =0; String newFirstName = “”; String newLastName = “”; double newScores = 0; double average=0; while (fileIn.hasNext()) { firstName = fileIn.next(); lastName = fileIn.nextLine(); scores = fileIn.nextDouble(); fileIn.nextLine(); count ++; sum += scores; if(scores > average){ newFirstName = firstName; newLastName = lastName; newScores = scores; } } fileIn.close(); average = sum/count; System.out.printf(“Average grade is %.2f%n”,average); System.out.println(“Students with grades > average”); System.out.printf(“%10s %8s %8s%n”,”First”,”Last”,”Score”); System.out.printf(“%10s %8s %8.2f”, newFirstName, newLastName, newScores); } }} Thank you! Computer Science Engineering & Technology Java Programming ACDCC CMPP269 Share QuestionEmailCopy link Comments (0)