Code:
import java.io.FileWriter;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
abstract class Person {
private String fullName;
private String id;
public Person() {
this.fullName = “Undefined”;
this.id = “Undefined”;
}
public Person(String id, String fullName) {
this.fullName = fullName;
this.id = id;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getFullName() {
return this.fullName;
}
public void setId(String id) {
this.id = id;
}
public String getId() {
return this.id;
}
public abstract void print();
public abstract void report(FileWriter writer) throws IOException;
}
class Student extends Person {
private double gpa;
private int creditHours;
public Student() {
super();
this.gpa = 0.0;
this.creditHours = 0;
}
public Student(String id, String fullName, double gpa, int creditHours) {
super(id, fullName);
this.gpa = gpa;
this.creditHours = creditHours;
}
public void setGpa(double gpa) {
this.gpa = gpa;
}
public double getGpa() {
return this.gpa;
}
public void setCreditHours(int creditHours) {
this.creditHours = creditHours;
}
public int getCreditHours() {
return creditHours;
}
@Override
public void print() {
DecimalFormat decimalFormat = new DecimalFormat(“#.##”);
System.out.println(“Here is the tuition invoice for ” + this.getFullName());
System.out.println(“—————————————————–“);
System.out.println(this.getFullName() + “tttt” + this.getId());
System.out.println(“Credit Hours: ” + this.getCreditHours() + ” ($236.45/credit hour)”);
System.out.println(“Fees: $52”);
double total = this.getCreditHours() * 236.45 + 52.0;
double discount = 0;
if (this.getGpa() >= 3.85) {
discount = total * 0.25;
}
System.out.println(“Total payment(after discount): $” + decimalFormat.format(total – discount) + “tttt($” + discount + ” discount applied)”);
System.out.println(“—————————————————–“);
}
@Override
public void report( FileWriter myWriter ) throws IOException {
myWriter.write(“n”+this.getFullName());
myWriter.write(“nID:” + this.getId());
myWriter.write(“nGpa:” + this.getGpa());
myWriter.write(“nCredit hours:” + this.getCreditHours());
myWriter.write(“n”);
}
}
abstract class Employee extends Person {
private String department;
public Employee() {
super();
// Default Value
this.department = “Mathematics”;
}
public Employee(String id, String fullName, String department) {
super(id, fullName);
this.department = department;
}
public void setDepartent(String department) {
this.department = department;
}
public String getDepartment() {
return this.department;
}
}
class Faculty extends Employee {
private String rank;
public Faculty() {
super();
this.rank = “Adjunct”;
}
public Faculty(String id, String fullName, String department, String rank) {
super(id, fullName, department);
this.rank = rank;
}
public void setRank(String rank) {
this.rank = rank;
}
public String getRank() {
return this.rank;
}
@Override
public void print() {
System.out.println(“—————————————————–“);
System.out.println(this.getFullName() + “tttt” + this.getId());
System.out.println(this.getDepartment() + ” Department, ” + this.getRank());
System.out.println(“—————————————————–“);
}
@Override
public void report(FileWriter myWriter) throws IOException {
myWriter.write(“n”+this.getFullName());
myWriter.write(“nID:” + this.getId());
myWriter.write(“n”+this.getDepartment() + “,” + this.getRank());
}
}
class Staff extends Employee {
private String status;
public Staff() {
super();
this.status = “Full Time”;
}
public Staff(String id, String fullName, String department, String status) {
super(id, fullName, department);
this.status = status;
}
public void setStatus(String rank) {
this.status = rank;
}
public String getStatus() {
return this.status;
}
@Override
public void print() {
System.out.println(“—————————————————–“);
System.out.println(this.getFullName() + “tttt” + this.getId());
System.out.println(this.getDepartment() + ” Department, ” + this.getStatus());
System.out.println(“—————————————————–“);
}
@Override
public void report(FileWriter myWriter) throws IOException {
myWriter.write(“n”+this.getFullName());
myWriter.write(“nID:” + this.getId());
myWriter.write(“n”+this.getDepartment() + “,” + this.getStatus());
}
}
public class Main {
FileWriter myWriter ;
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
Person[] persons = new Person[100];
Scanner input = new Scanner(System.in);
int count = 0;
String fullName, id, rank, department, status, report;
int creditHours;
double gpa;
boolean flag;
System.out.println(“tWelcome to my Personal Management Programn”);
System.out.println(“Choose one of the options:”);
while (true) {
System.out.println();
System.out.println(“1- Enter the information of a faculty”);
System.out.println(“2- Enter the information of a student”);
System.out.println(“3- Print tuition invoice for a student”);
System.out.println(“4- Print faculty information”);
System.out.println(“5- Enter the information of a staff member”);
System.out.println(“6- Print the information of a staff member”);
System.out.println(“7- Exit program”);
System.out.println();
System.out.print(“tEnter your selection: “);
String option = scn.next();
switch (option) {
case “1”:
System.out.println(“Enter the faculty info: “);
System.out.print(“tName of the faculty: “);
fullName = input.nextLine();
while(true)
{
System.out.print(“tID: “);
id = input.nextLine();
if(id.length()==6&&Character.isAlphabetic(id.charAt(0))&&Character.isAlphabetic(id.charAt(1))&&Character.isDigit(id.charAt(2))&&Character.isDigit(id.charAt(3))&&Character.isDigit(id.charAt(4))&&Character.isDigit(id.charAt(5)))
{
break;
}
else {
System.out.printf(“Invalid ID format. Must be LetterLetterDigitDigitDigitDigitn”);
}
}
while (true) {
System.out.print(“tRank: “);
rank = input.nextLine();
if (rank.equalsIgnoreCase(“Adjunct”)) {
rank = “Adjunct”;
break;
} else if (rank.equalsIgnoreCase(“Professor”)) {
rank = “Professor”;
break;
} else {
System.out.printf(“tt”%s”” is invalid%n””