Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I keep getting the error fir my java codestudents.txt not found please help me fix import java.io . File; import java.io . FileNotFoundException; import java.util.ArrayList;
I keep getting the error fir my java code"students.txt not found" please help me fix import java.ioFile;
import java.ioFileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
class Student
private String name;
private int creditHours;
private int qualityPoints;
public StudentString name, int creditHours, int qualityPoints
this.name name;
this.creditHours creditHours;
this.qualityPoints qualityPoints;
public double gpa
return double qualityPoints creditHours;
public boolean eligibleForHonorSociety
return gpa HonorSociety.getGpaThreshold;
@Override
public String toString
return "Name: name GPA: gpa;
public static void setGpaThresholddouble threshold
HonorSociety.setGpaThresholdthreshold;
class Undergraduate extends Student
private String year;
public UndergraduateString name, int creditHours, int qualityPoints, String year
supername creditHours, qualityPoints;
this.year year;
@Override
public boolean eligibleForHonorSociety
return super.eligibleForHonorSociety && yearequalsJunior year.equalsSenior;
@Override
public String toString
return super.toString Year: year;
class Graduate extends Student
private String degree;
public GraduateString name, int creditHours, int qualityPoints, String degree
supername creditHours, qualityPoints;
this.degree degree;
@Override
public boolean eligibleForHonorSociety
return super.eligibleForHonorSociety && degree.equalsMasters;
@Override
public String toString
return super.toString Degree: degree;
class HonorSociety
private static double gpaThreshold;
public static double getGpaThreshold
return gpaThreshold;
public static void setGpaThresholddouble threshold
gpaThreshold threshold;
System.out.printlnHonor Society GPA Threshold set to: gpaThreshold;
public class Project
public static void mainString args
ArrayList students new ArrayList;
try
Scanner scanner new Scannernew Filestudentstxt;
double totalGpa ;
int count ;
while scannerhasNextLine
String line scanner.nextLine;
String data line.split;
String name data data;
int creditHours Integer.parseIntdata;
int qualityPoints Integer.parseIntdata;
if datalength
Undergraduate
String year data;
students.addnew Undergraduatename creditHours, qualityPoints, year;
else if datalength
Graduate
String degree data;
students.addnew Graduatename creditHours, qualityPoints, degree;
totalGpa students.getcountgpa;
count;
if count
double averageGpa totalGpa count;
Student.setGpaThreshold averageGpa;
scanner.close;
catch FileNotFoundException e
System.out.printlnError: students.txt not found.";
return;
System.out.printlnHonor Society Members:";
for Student student : students
if studenteligibleForHonorSociety
System.out.printlnstudent;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started