Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can I get UML diagram, and a testplan with 5 examples for my follwing JAVA code?: import java.io . File; import java.io . FileNotFoundException; import
Can I get UML diagram, and a testplan with examples for my follwing JAVA code?: import java.ioFile;
import java.ioFileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
Base class representing a student
class Student
private String name;
private int creditHours;
private int qualityPoints;
Constructor to initialize student attributes
public StudentString name, int creditHours, int qualityPoints
this.name name;
this.creditHours creditHours;
this.qualityPoints qualityPoints;
Method to calculate GPA
public double gpa
return double qualityPoints creditHours;
Method to check eligibility for honor society based on GPA threshold
public boolean eligibleForHonorSociety
return gpa HonorSociety.getGpaThreshold;
Method to return a string representation of the student
@Override
public String toString
return "Name: name GPA: gpa;
Static method to set GPA threshold in the HonorSociety class
public static void setGpaThresholddouble threshold
HonorSociety.setGpaThresholdthreshold;
Class representing an undergraduate student, inheriting from Student
class Undergraduate extends Student
private String year;
Constructor to initialize undergraduate student attributes
public UndergraduateString name, int creditHours, int qualityPoints, String year
supername creditHours, qualityPoints;
this.year year;
Overridden method to check eligibility for honor society
@Override
public boolean eligibleForHonorSociety
return super.eligibleForHonorSociety && yearequalsJunior year.equalsSenior;
Overridden method to return a string representation of the undergraduate student
@Override
public String toString
return super.toString Year: year;
Class representing a graduate student, inheriting from Student
class Graduate extends Student
private String degree;
Constructor to initialize graduate student attributes
public GraduateString name, int creditHours, int qualityPoints, String degree
supername creditHours, qualityPoints;
this.degree degree;
Overridden method to check eligibility for honor society
@Override
public boolean eligibleForHonorSociety
return super.eligibleForHonorSociety && degree.equalsMasters;
Overridden method to return a string representation of the graduate student
@Override
public String toString
return super.toString Degree: degree;
Class representing the honor society with a static GPA threshold
class HonorSociety
private static double gpaThreshold;
Method to get the GPA threshold
public static double getGpaThreshold
return gpaThreshold;
Method to set the GPA threshold and print it
public static void setGpaThresholddouble threshold
gpaThreshold threshold;
System.out.printlnHonor Society GPA Threshold set to: gpaThreshold;
Main class for the project
public class CMSCPROJNW
public static void mainString args
ArrayList students new ArrayList;
try
Specify the path to the students.txt file
Scanner scanner new Scannernew Filestudentstxt;
double totalGpa ;
int count ;
Read student data from the file
while scannerhasNextLine
String line scanner.nextLine;
String data line.split;
String name data data;
int creditHours Integer.parseIntdata;
int qualityPoints Integer.parseIntdata;
if datalength
Create and add an undergraduate student
String year data;
students.addnew Undergraduatename creditHours, qualityPoints, year;
else if datalength
Create and add a graduate student
String degree data;
students.addnew Graduatename creditHours, qualityPoints, degree;
Accumulate total GPA
totalGpa students.getcountgpa;
count;
Calculate average GPA and set the GPA threshold
if
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