Smart College wants you to develop a set of classes for them to use in various s
ID: 3636054 • Letter: S
Question
Smart College wants you to develop a set of classes for them to use in various student service and personnelapplications. Classes you need to design include the following:
?
Person – A Person contains a first name, last name, street address, post code and phone number. The class also includes a method that sets each field using a series of dialog boxes and a display method that displays all of a Person’s information on a single line at the command line on the screen.
? CollegeEmployee – CollegeEmployee descends from Person. A CollegeEmployee also includes a staff id, an annual salary and a department name, as well as method that override the Person methods to accept and display all CollegeEmpolyee data.
?
Faculty – Faculty descends from CollegeEmployee. This class also includes a boolean field that indicates whether the Faculty member is tenured, as well as methods that override the
CollegeEmployee methods to accept and display this additional information.
? Student – Student descends from Person. In addition to the fields available in Person, a Student contains a major field of study and a grade point average, as well as methods that override the Person methods to accept and display these additional facts.
Write an application named CollegeList that declares an array of four “regular” CollegeEmployee, three Faculty, and seven Students. prompt the user to specify which type of person’s data will be entered (‘C’, ‘F’, or ‘S’), or allow the user to quit (‘Q’). While the user chooses to continue (that is, does not quit), accept data entry for the appropriate type of Person. If the user attempts to enter data for more than four CollegeEmployee, three Faculty, or seven Students, display an error message.
When the user quits, display a report on the screen listing each group of Persons under the appropriate heading “College Employees” – in alphabetical order by their last name, “Faculty” – in alphabetical order by their last name, or “Students” – in ascending order by their grade point average. If the user has not entered the data
for one or more types of Persons during a session, display an appropriate message under the appropriate heading.
Explanation / Answer
// I am posting Large no code in which some code may miss, if so please write to me back that i can Post missing code . package javaapplication2; import java.util.Scanner; /** * Programe 1: Person.java * @author DEEPU */ public class Person { protected String firstName; protected String lastName; protected String streetAddress; protected String postCode; protected String phoneNumber; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getPhoneNumber() { return phoneNumber; } public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } public String getPostCode() { return postCode; } public void setPostCode(String postCode) { this.postCode = postCode; } public String getStreetAddress() { return streetAddress; } public void setStreetAddress(String streetAddress) { this.streetAddress = streetAddress; } public Person() { } public Person(Scanner scan) { setPersonData(scan); } public Person(String firstName, String lastName, String streetAddress, String postCode, String phoneNumber) { this.firstName = firstName; this.lastName = lastName; this.streetAddress = streetAddress; this.postCode = postCode; this.phoneNumber = phoneNumber; } public String toString() { StringBuffer sb= new StringBuffer(); sb.append(this.firstName).append(", "); sb.append(this.lastName).append(", "); sb.append(this.streetAddress).append("-"); sb.append(this.postCode).append(", "); sb.append("Ph:").append(this.phoneNumber); return sb.toString(); } public void setPersonData(Scanner scan){ String next=""; System.out.println("Please enter first name:"); next=scan.next(); this.setFirstName(next); System.out.println("Please enter last name:"); next=scan.next(); this.setLastName(next); System.out.println("Please enter street address:"); next=scan.next(); this.setStreetAddress(next); System.out.println("Please enter postcode:"); next=scan.next(); this.setPostCode(next); System.out.println("Please enter phone number:"); next=scan.next(); this.setPhoneNumber(next); } } package javaapplication2; import java.util.Scanner; /** * Programe 2: CollegeEmployee.java * @author DEEPU */ public class CollegeEmployee extends Person { protected String staffId; protected double annualSalary; protected String departmentName; public double getAnnualSalary() { return annualSalary; } public void setAnnualSalary(double annualSalary) { this.annualSalary = annualSalary; } public String getDepartmentName() { return departmentName; } public void setDepartmentName(String departmentName) { this.departmentName = departmentName; } public String getStaffId() { return staffId; } public void setStaffId(String staffId) { this.staffId = staffId; } public CollegeEmployee(String firstName, String lastName, String streetAddress, String postCode, String phoneNumber, String staffId, double annualSalary, String departmentName) { super(firstName, lastName, streetAddress, postCode, phoneNumber); this.staffId = staffId; this.annualSalary = annualSalary; this.departmentName = departmentName; } public CollegeEmployee(String staffId, double annualSalary, String departmentName) { this.staffId = staffId; this.annualSalary = annualSalary; this.departmentName = departmentName; } @Override public String toString() { StringBuffer sb= new StringBuffer(); sb.append("Staff ID:").append(this.staffId); sb.append(" "); sb.append("Department:").append( this.departmentName); sb.append(" "); sb.append("Anual Salary:").append( this.annualSalary ); sb.append(" "); sb.append("Employee details:"); sb.append(" "); sb.append(super.firstName).append(" "); sb.append(super.lastName).append(", "); sb.append(super.streetAddress).append("-"); sb.append(super.postCode).append(", "); sb.append("Ph:").append(super.phoneNumber); return sb.toString(); } public CollegeEmployee() { } public CollegeEmployee(Scanner scan) { setCollegeEmployeeData( scan); } public void setCollegeEmployeeData(Scanner scan){ String next=""; System.out.println("Please enter employee id:"); next=scan.next(); this.setStaffId(next); System.out.println("Please enter employee department:"); next=scan.next(); this.setDepartmentName(next); System.out.println("Please enter employee anual salary:"); this.setAnnualSalary(scan.nextDouble()); System.out.println("Please enter employee Details:"); System.out.println("Please enter first name:"); next=scan.next(); this.setFirstName(next); System.out.println("Please enter last name:"); next=scan.next(); this.setLastName(next); System.out.println("Please enter street address:"); next=scan.next(); this.setStreetAddress(next); System.out.println("Please enter postcode:"); next=scan.next(); this.setPostCode(next); System.out.println("Please enter phone number:"); next=scan.next(); this.setPhoneNumber(next); } } package javaapplication2; import java.util.Scanner; /** * Programe 3: Faculty.java * @author DEEPU */ public class Faculty extends CollegeEmployee { protected boolean isTenured; public Faculty(boolean isTenured) { this.isTenured = isTenured; } public Faculty(Scanner scan) { setFacultyData(scan); } public Faculty() { } public Faculty(String staffId, double annualSalary, String departmentName, boolean isTenured) { super(staffId, annualSalary, departmentName); this.isTenured = isTenured; } public Faculty(String firstName, String lastName, String streetAddress, String postCode, String phoneNumber, String staffId, double annualSalary, String departmentName, boolean isTenured) { super(firstName, lastName, streetAddress, postCode, phoneNumber, staffId, annualSalary, departmentName); this.isTenured = isTenured; } public boolean isTenured() { return isTenured; } public void setTenured(boolean isTenured) { this.isTenured = isTenured; } @Override public double getAnnualSalary() { return super.getAnnualSalary(); } @Override public String getDepartmentName() { return super.getDepartmentName(); } @Override public void setAnnualSalary(double annualSalary) { super.setAnnualSalary(annualSalary); } @Override public void setDepartmentName(String departmentName) { super.setDepartmentName(departmentName); } @Override public String toString() { StringBuffer sb= new StringBuffer(); sb.append("Staff ID:").append(super.staffId); sb.append(" "); sb.append("Department:").append( super.departmentName); sb.append(" "); sb.append("Anual Salary:").append( super.annualSalary ); sb.append(" "); sb.append("Is Tenured : ").append((isTenured() ? "Yes" : "NO")); sb.append(" "); sb.append("Employee details:"); sb.append(" "); sb.append(super.firstName).append(" "); sb.append(super.lastName).append(", "); sb.append(super.streetAddress).append("-"); sb.append(super.postCode).append(", "); sb.append("Ph:").append(super.phoneNumber); return sb.toString(); } public void setFacultyData(Scanner scan){ String next=""; System.out.println("Please enter employee id:"); next=scan.next(); this.setStaffId(next); System.out.println("Please enter employee department:"); next=scan.next(); this.setDepartmentName(next); System.out.println(" is employee tenured (y/n):"); next=scan.next(); if("yes".equalsIgnoreCase(next) ||"y".equalsIgnoreCase(next) ){ this.setTenured(true); }else{ this.setTenured(false); } System.out.println("Please enter Faculty anual salary:"); this.setAnnualSalary(scan.nextDouble()); System.out.println("Please enter Faculty Details:"); System.out.println("Please enter first name:"); next=scan.next(); this.setFirstName(next); System.out.println("Please enter last name:"); next=scan.next(); this.setLastName(next); System.out.println("Please enter street address:"); next=scan.next(); this.setStreetAddress(next); System.out.println("Please enter postcode:"); next=scan.next(); this.setPostCode(next); System.out.println("Please enter phone number:"); next=scan.next(); this.setPhoneNumber(next); } } package javaapplication2; import java.util.Scanner; /** * Programe 4: Student.java * @author DEEPU */ public class Student extends Person{ private String majorFieldOfStudy; private Double gpa; public Double getGpa() { return gpa; } public void setGpa(Double gpa) { this.gpa = gpa; } public String getMajorFieldOfStudy() { return majorFieldOfStudy; } public void setMajorFieldOfStudy(String majorFieldOfStudy) { this.majorFieldOfStudy = majorFieldOfStudy; } public Student(String firstName, String lastName, String streetAddress, String postCode, String phoneNumber, String majorFieldOfStudy, Double gpa) { super(firstName, lastName, streetAddress, postCode, phoneNumber); this.majorFieldOfStudy = majorFieldOfStudy; this.gpa = gpa; } public Student(String majorFieldOfStudy, Double gpa) { this.majorFieldOfStudy = majorFieldOfStudy; this.gpa = gpa; } @Override public String getFirstName() { return super.getFirstName(); } @Override public String getLastName() { return super.getLastName(); } @Override public String getPhoneNumber() { return super.getPhoneNumber(); } @Override public String getPostCode() { return super.getPostCode(); } @Override public String getStreetAddress() { return super.getStreetAddress(); } @Override public void setFirstName(String firstName) { super.setFirstName(firstName); } @Override public void setLastName(String lastName) { super.setLastName(lastName); } @Override public void setPhoneNumber(String phoneNumber) { super.setPhoneNumber(phoneNumber); } @Override public void setPostCode(String postCode) { super.setPostCode(postCode); } @Override public void setStreetAddress(String streetAddress) { super.setStreetAddress(streetAddress); } @Override public String toString() { StringBuffer sb= new StringBuffer(); sb.append(" Major Field Of Study : ").append(this.majorFieldOfStudy).append(", "); sb.append(" GPA :").append(this.gpa).append(" "); sb.append("Student details :").append(" "); sb.append(this.firstName).append(" "); sb.append(this.lastName).append(", "); sb.append(this.streetAddress).append("-"); sb.append(this.postCode).append(", "); sb.append("Ph:").append(this.phoneNumber); return sb.toString(); } public void setStudentData(Scanner scan){ String next=""; System.out.println("Please enter Student Details:"); System.out.println("Please enter first name:"); next=scan.next(); this.setFirstName(next); System.out.println("Please enter last name:"); next=scan.next(); this.setLastName(next); System.out.println("Please enter street address:"); next=scan.next(); this.setStreetAddress(next); System.out.println("Please enter postcode:"); next=scan.next(); this.setPostCode(next); System.out.println("Please enter phone number:"); next=scan.next(); this.setPhoneNumber(next); System.out.println("Please enter Student majorFieldOfStudy:"); next=scan.next(); this.setMajorFieldOfStudy(next); System.out.println("Please enter Student GPA:"); this.setGpa(scan.nextDouble()); } public Student() { } public Student(Scanner scan) { setStudentData(scan); } } package javaapplication2; import java.util.Scanner; /** * Programe 4: CollegeList.java * @author DEEPU */ public class CollegeList { private CollegeEmployee collegeEmployee[]; private Faculty faculty[]; private Student student[]; private int noOfStudents; private int noOfEmployes; private int noOffaculty; private final int MAX_NO_OF_STUDENTS = 7 ; private final int MAX_NO_OF_EMPLOYES = 4; private final int MAX_NO_OF_FACULTY = 3; public CollegeList(CollegeEmployee[] collegeEmployee, Faculty[] faculty, Student[] student) { this.collegeEmployee = new CollegeEmployee[MAX_NO_OF_EMPLOYES]; this.faculty = new Faculty[MAX_NO_OF_FACULTY]; this.student = new Student[MAX_NO_OF_STUDENTS]; this.collegeEmployee = collegeEmployee; this.faculty = faculty; this.student = student; this.noOfEmployes = collegeEmployee.length; this.noOfStudents = student.length; this.noOffaculty = faculty.length; } public int getNoOfEmployes() { return noOfEmployes; } public void setNoOfEmployes(int noOfEmployes) { this.noOfEmployes = noOfEmployes; } public int getNoOfStudents() { return noOfStudents; } public void setNoOfStudents(int noOfStudents) { this.noOfStudents = noOfStudents; } public int getNoOffaculty() { return noOffaculty; } public void setNoOffaculty(int noOffaculty) { this.noOffaculty = noOffaculty; } public CollegeList() { this.collegeEmployee = new CollegeEmployee[MAX_NO_OF_EMPLOYES]; this.faculty = new Faculty[MAX_NO_OF_FACULTY]; this.student = new Student[MAX_NO_OF_STUDENTS]; this.noOfEmployes = 0; this.noOfStudents = 0; this.noOffaculty = 0; } public CollegeEmployee[] getCollegeEmployee() { return collegeEmployee; } public void setCollegeEmployee(CollegeEmployee[] collegeEmployee) { this.collegeEmployee = collegeEmployee; } public Faculty[] getFaculty() { return faculty; } public void setFaculty(Faculty[] faculty) { this.faculty = faculty; } public Student[] getStudent() { return student; } public void setStudent(Student[] student) { this.student = student; } public void addFaculty(Faculty faculty){ if(noOffacultyRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.