Question: May I get a testplan with 5 examples for my java code: import java.io . BufferedReader; import java.io . FileReader; import java.io . IOException; import
May I get a testplan with examples for my java code: import java.ioBufferedReader;
import java.ioFileReader;
import java.ioIOException;
import java.util.ArrayList;
import java.util.List;
public class Project
private static final String FILENAME "students.txt;
private static final double MAXGPA ;
private static double gpaThreshold;
public static void mainString args
List students new ArrayList;
double totalGpa ;
int numStudents ;
try BufferedReader br new BufferedReadernew FileReaderFILENAME
String line;
while line brreadLine null
String studentInfo line.splits;
String name studentInfo studentInfo;
int creditHours Integer.parseIntstudentInfo;
int qualityPoints Integer.parseIntstudentInfo;
String yearOrDegree studentInfo;
Student student;
if yearOrDegreeequalsFreshman yearOrDegree.equalsSophomore yearOrDegree.equalsJunior yearOrDegree.equalsSenior
student new Undergraduatename creditHours, qualityPoints, yearOrDegree;
else
student new Graduatename creditHours, qualityPoints, yearOrDegree;
students.addstudent;
totalGpa student.calculateGpa;
numStudents;
catch IOException e
System.err.printlnError: File not found.";
System.exit;
double averageGpa totalGpa numStudents;
gpaThreshold averageGpa MAXGPA;
System.out.printlnGPA threshold: gpaThreshold;
System.out.println
Students eligible for honor society:";
for Student student : students
if studenteligibleForHonorSociety
System.out.printlnstudent;
abstract 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 calculateGpa
return double qualityPoints creditHours;
public boolean eligibleForHonorSociety
return calculateGpa gpaThreshold;
@Override
public String toString
return name : calculateGpa;
public static void setGpaThresholddouble threshold
gpaThreshold threshold;
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;
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.eligibleForHonorSocie && degree.equalsPhD;
@Override
public String toString
return super.toString degree;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
