JAVA Language
Write an Undergraduate subclass of student. Each Undergraduate has a major, degree (like BS or BA), number of credits earned, tuition balance, and gpa, in addition to name id, and phone as in the super class. Include constructors, get(), set(), pay(), toString(), and status() methods. the pa() method should accept an amount as parameter, print the current balance, update tuition balance by subtracting the amount from the current balance and print the new balance (for example pat (500) should decrease the current balance by 500 to get the new balance). the status() method should print" Congratulations! you are admitted into Honors List" if the gpa>=3.7, "your gpa is "+gpa+". you could raise it to 3.7 and be on Honors List " if gpa>=3.0 but 3.7 " your gpa is "+gpa+ try hard to raise your gpa " if gpa>=2 but <3.0, and fanally " you GPA has fallen below 2.0! you are on probation" if gpa<2.0 00 . [ UML 10 points class 30 points]
//Java Code
public class Student {
private String id;
private String name;
private String phone;
//Constructor
public Student(String id, String name, String phone) {
this.id = id;
this.name = name;
this.phone = phone;
}
//Default Constructor
public Student()
{
id ="";
name ="";
phone ="";
}
//getters and setters
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
@Override
public String toString() {
return "Student Id: "+id+"\nStudent Name: "+name+"\nStudent Phone: "+phone;
}
}
//========================================//
public class Undergraduate extends Student {
private String major;
private String degree;
private int numberOfCredits;
private double tuitionBalance;
private double gpa;
//Constructor
public Undergraduate(String id, String name, String phone, String major, String degree, int numberOfCredits, double tuitionBalance, double gpa) {
super(id, name, phone);
this.major = major;
this.degree = degree;
this.numberOfCredits = numberOfCredits;
this.tuitionBalance = tuitionBalance;
this.gpa = gpa;
}
public Undergraduate()
{
super();
major ="";
degree ="";
numberOfCredits =0;
tuitionBalance =0;
gpa =0;
}
//Getter and setter
public String getMajor() {
return major;
}
public void setMajor(String major) {
this.major = major;
}
public String getDegree() {
return degree;
}
public void setDegree(String degree) {
this.degree = degree;
}
public int getNumberOfCredits() {
return numberOfCredits;
}
public void setNumberOfCredits(int numberOfCredits) {
this.numberOfCredits = numberOfCredits;
}
public double getTuitionBalance() {
return tuitionBalance;
}
public void setTuitionBalance(double tuitionBalance) {
this.tuitionBalance = tuitionBalance;
}
public double getGpa() {
return gpa;
}
public void setGpa(double gpa) {
this.gpa = gpa;
}
public void pay(double amount)
{
System.out.println("Current Balance: $"+String.format("%.2f",tuitionBalance));
tuitionBalance-=amount;
System.out.println("Updated Balance: $"+String.format("%.2f",tuitionBalance));
}
public void status()
{
if(gpa >=3.7)
System.out.println(" Congratulations! you are admitted into Honors List");
else if(gpa>=3.0 && gpa< 3.7 )
System.out.println("your gpa is "+gpa+". you could raise it to 3.7 and be on Honors List");
else if(gpa>=2 && gpa <3.0)
System.out.println(" your gpa is "+gpa+ " try hard to raise your gpa");
else
System.out.println("you GPA has fallen below 2.0! you are on probation");
}
@Override
public String toString() {
return super.toString()+"\nMajor: "+major+"\nDegree: "+degree+"\n" +
"Number of Credits: "+numberOfCredits+"\nGPA: "+gpa;
}
}
//=================================//
public class TestStudent {
public static void main(String[] args)
{
Undergraduate undergraduate = new
Undergraduate("S101","Jack Ryan","(840)-234-4567","CS","BA",5,5000,3.8);
System.out.println(undergraduate);
undergraduate.pay(450);
undergraduate.status();
}
}
//Output

//UML

//If you need any help regarding this solution.......... please leave a comment..... thanks
JAVA Language Write an Undergraduate subclass of student. Each Undergraduate has a major, degree (like BS...
Must be written in JAVA Code Write a program that will read in a file of student academic credit data and create a list of students on academic warning. The list of students on warning will be written to a file. Each line of the input file will contain the student name (a single String with no spaces), the number of semester hours earned (an integer), the total quality points earned (a double). The following shows part of a typical...