Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you write a test plan table and UML diagram for the program below import java.util.ArrayList; class Student { private String name; private int credits;

Can you write a test plan table and UML diagram for the program below
import java.util.ArrayList;
class Student {
private String name;
private int credits;
private int Qpoints;
private static double gpaThreshold; // Static field for GPA threshold
public Student(String name, int credits, int Qpoints){
this.name = name;
this.credits = credits;
this.Qpoints = Qpoints;
}
public double gpa(){
if (credits ==0){
return 0;
}
return (double) Qpoints / credits;
}
public boolean eligibleForHonorSociety(){
return gpa()>= gpaThreshold;
}
public String toString(){
return "Name: "+ name +", GPA: "+ gpa();
}
public static double getGpaThreshold(){
return gpaThreshold;
}
public static void setGpaThreshold(double threshold){
gpaThreshold = threshold;
}
}
class Undergraduate extends Student {
private String year;
public Undergraduate(String name, int credits, int Qpoints, String year){
super(name, credits, Qpoints);
this.year = year;
}
@Override
public boolean eligibleForHonorSociety(){
return super.eligibleForHonorSociety() && (year.equals("Junior")|| year.equals("Senior"));
}
@Override
public String toString(){
return super.toString()+", Year: "+ year;
}
}
class Graduate extends Student {
private String degreeSought;
public Graduate(String name, int credits, int Qpoints, String degreeSought){
super(name, credits, Qpoints);
this.degreeSought = degreeSought;
}
@Override
public boolean eligibleForHonorSociety(){
return super.eligibleForHonorSociety() && degreeSought.equals("Masters");
}
@Override
public String toString(){
return super.toString()+", Degree Sought: "+ degreeSought;
}
}
public class Project2{
public static void main(String[] args){
ArrayList students = new ArrayList<>();
double totalGPA =0;
// Read student information from a text file
// Assuming the text file is properly formatted and named "students.txt"
// For demonstration purposes, manually adding students
students.add(new Undergraduate("Brown, William", 72,230, "Junior"));
students.add(new Graduate("Johnson, Mary", 21,77, "Masters"));
students.add(new Undergraduate("Jones, Sally", 32,95, "Sophomore"));
// Calculate total GPA and create Student objects
for (Student student : students){
totalGPA += student.gpa();
}
// Calculate average GPA
double averageGPA = students.isEmpty()?0 : totalGPA / students.size();
// Set GPA threshold for honor society membership
Student.setGpaThreshold((averageGPA +4.0)/2.0);
System.out.println("GPA Threshold: "+ Student.getGpaThreshold());
// Display eligible students
System.out.println("Eligible Students:");
for (Student student : students){
if (student.eligibleForHonorSociety()){
System.out.println(student);
}
}
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions

Question

Calculate the missing values for the promissory notes described

Answered: 1 week ago