Question

Develop a set of classes for a college to use in various student service and personnel applications. Classes you need to design include the following: • Person — A Person contains the following fields...

Develop a set of classes for a college to use in various student service and personnel applications. Classes you need to design include the following:

• Person — A Person contains the following fields, all of type String: firstName, lastName, address, zip, phone. The class also includes a method named setData() that sets each data field by prompting the user for each value and a display method that displays all of a Person’s information on a single line at the command line on the screen. For example, Joe Smith 111 N Student Way 88888 888-888-8888.

• CollegeEmployee— CollegeEmployeedescends from Person. A CollegeEmployeealso includes a Social Security number (ssn of type String), an annual salary (annualSalary of type double), and a department name (dept of type String), as well as methods that override the setData and displaymethods to accept and display all CollegeEmployeedata in addition to the Person data. The displaymethod should display the Person fields on one line, and the additional CollegeEmployeefields on the next, for example:

Jane Smith 111-W-College-Rd 88888 888-888-8888
SSN: 123-45-6789 Salary $80000.0 Department: CS

• Faculty — Facultydescends from CollegeEmployee. This class also includes a Boolean field named isTenured that indicates whether the Facultymember is tenured, as well as setData and displaymethods that override the CollegeEmployeemethods to accept and display this additional piece of information. An example of the output from display is:

Jane Smith 111-W-College-Rd 88888 888-888-8888
SSN: 123-45-6789 Salary $90000.0 Department: SE
Faculty member is tenured

Note: If the faculty member is not tenured, the third line should read Faculty member is not tenured.

• Student— Studentdescends from Person. In addition to the fields available in Person, a Student contains a major field of study (major of type String) and a grade point average (gpa of type double) as well as setDataand displaymethods that override the Person methods to accept and display these additional facts. An example of the output from display is:

Joe Smith 111-N-Student-Lane 88888 888-888-8888
Major: Biology  GPA: 3.47

Note: There should be two spaces before 'GPA' on the second line.

Write an application named CollegeList that declares an array of four “regular” CollegeEmployeeobjects, three Faculty objects, and seven Student objects. 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 CollegeEmployeeobjects, three Faculty objects, or seven Studentobjects, display an error message. When the user quits, display a report on the screen listing each group of Personsunder the appropriate heading of “College Employees,” “Faculty,” or “Students.” If the user has not entered data for one or more types of Personsduring a session, display an appropriate message under the appropriate heading.

The following are checked:

Define setData in Personclass

Define display in Person class

Define setData in CollegeEmployee class

Define display in CollegeEmployee class

Define setData in Faculty class

Define display in Faculty class

Define display in Student class

This has to be run in an online sandbox, JOption doesn't seem to work well with it. It appears to be searching for a specific pattern (like: super\.setData\s*\(\s*\))

0 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1

/*************************Person.java*******************/

package inheritance;

import java.util.Scanner;

public class Person {

   private String firstName;
   private String lastName;
   private String address;
   private String zip;
   private String phone;

   public Person() {

       setData();
   }

   public void setData() {

       Scanner scan = new Scanner(System.in);

       System.out.print("Enter the Person's first name: ");
       this.firstName = scan.nextLine();
       System.out.print("Enter the Person's last name: ");
       this.lastName = scan.nextLine();
       System.out.print("Enter the Person's address: ");
       this.address = scan.nextLine();
       System.out.print("Enter the Person's zipcode: ");
       this.zip = scan.nextLine();
       System.out.print("Enter the Person's phone: ");
       this.phone = scan.nextLine();

   }

   public String display() {
       return firstName + " " + lastName + " " + address + " " + zip + " " + phone;
   }

}
/**********************************CollegeEmployee.java**************************/

package inheritance;

import java.util.Scanner;

public class CollegeEmployee extends Person {

   private String ssn;
   private double salary;
   private String department;

   public CollegeEmployee() {
   }

   @Override
   public void setData() {
       super.setData();
       Scanner scan = new Scanner(System.in);
       System.out.print("Enter SSN: ");
       this.ssn = scan.nextLine();
       System.out.print("Enter Salary: ");
       this.salary = scan.nextDouble();
       scan.nextLine();
       System.out.print("Department: ");
       this.department = scan.nextLine();
   }

   @Override
   public String display() {
       return super.display() + "\n" + "SSN: " + ssn + " Salary $" + salary + " Department: " + department;
   }

}

/**********************************Feculty.java*****************************/

package inheritance;

import java.util.Scanner;

public class Faculty extends CollegeEmployee {

   private boolean isTenured;

   public Faculty() {

   }

   @Override
   public void setData() {
       super.setData();
       Scanner scan = new Scanner(System.in);
       System.out.print("Feculty memeber is: ");
       this.isTenured = scan.nextBoolean();

   }

   @Override
   public String display() {
       if (isTenured) {
           return super.display() + " Faculty member is tenured";
       } else {
           return super.display() + " Faculty member is not tenured";
       }
   }

}
/***************************************Student.java*********************************/

package inheritance;

import java.util.Scanner;

public class Student extends Person {

   private String major;
   private double gpa;

   public Student() {

   }

   @Override
   public void setData() {
       super.setData();
       Scanner scan = new Scanner(System.in);
       System.out.print("Enter the student's major: ");
       this.major = scan.nextLine();
       System.out.print("Enter Student's GPA: ");
       this.gpa = scan.nextDouble();
       scan.nextLine();
   }

   @Override
   public String display() {

       return super.display() + "\n" + " Major: " + major + " GPA: " + gpa;
   }

}
/*******************************CollegeList.java*******************************/

package inheritance;

import java.util.Scanner;

public class CollegeList {

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);
       Person[] persons = new Person[14];
       String choice;
       int i = 0;
       do {
           menu();
           System.out.print("Enter the choice: ");
           choice = scan.nextLine();
           switch (choice.toUpperCase().charAt(0)) {
           case 'C':
               persons[i] = new CollegeEmployee();
               i++;
               break;
           case 'F':
               persons[i] = new Faculty();
               i++;
               break;
           case 'S':
               persons[i] = new Student();
               i++;
               break;
           case 'Q':
               try {
                   for (Person person : persons) {

                       System.out.println(person.display());
                       System.out.println();
                   }
               } catch (Exception e) {

               }

               break;

           default:
               System.out.println("Invalid choice!try again");
               break;
           }

       } while (choice.toUpperCase().charAt(0) != 'Q');

   }

   public static void menu() {

       System.out.println("C)ollege Employee.\n" + "F)eculty.\n" + "S)tudent.\n" + "Q)uit.");
   }
}
/*******************output*********************/

C)ollege Employee.
F)eculty.
S)tudent.
Q)uit.
Enter the choice: C
Enter the Person's first name: jane
Enter the Person's last name: Smith
Enter the Person's address: 111-W-College-Rd
Enter the Person's zipcode: 88888
Enter the Person's phone: 888-888-8888
Enter SSN: 123-45-6789
Enter Salary: 80000
Department: CS
C)ollege Employee.
F)eculty.
S)tudent.
Q)uit.
Enter the choice: Q
jane Smith 111-W-College-Rd 88888 888-888-8888
SSN: 123-45-6789 Salary $80000.0 Department: CS

E Console X <terminated CollegeList [Java Applicationl C:\Program FilesJavaire1.8.0 131 biniavaw C)ollege Employee F)eculty S

Thanks a lot, Please let m e know if you have any problem............

Add a comment
Know the answer?
Add Answer to:
Develop a set of classes for a college to use in various student service and personnel applications. Classes you need to design include the following: • Person — A Person contains the following fields...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Design a class named Person and its two derived classes named Student and Employee. MakeFaculty and Staff derived classes of Employee

    In Java(The Person, Student, Employee, Faculty, and Staff classes)Design a class named Person and its two derived classes named Student and Employee. MakeFaculty and Staff derived classes of Employee. A person has a name, address, phone number, and e-mail address. A student has a class status (freshman, sophomore, junior, or senior). An employee has an office, salary, and date hired. Define a class namedMyDate that contains the fields year, month, and day. A faculty member has office hours and a rank....

  • Create a class hierarchy to be used in a university setting. The classes are as follows:...

    Create a class hierarchy to be used in a university setting. The classes are as follows: The base class is Person. The class should have 3 data members: personID (integer), firstName(string), and lastName(string). The class should also have a static data member called nextID which is used to assign an ID number to each object created (personID). All data members must be private. Create the following member functions: o Accessor functions to allow access to first name and last name...

  • Java: student directory GUI You need to implement three classes: Person Student StudentDirectory StudentMain Start by...

    Java: student directory GUI You need to implement three classes: Person Student StudentDirectory StudentMain Start by implementing Person and Student classes. Once you are sure you can serialize and deserialize and ArrayList of Students to and from a file, move on to building the GUI application. Person: The Person class should implement serializable interface. It contains the following: Person's first name (String) Person's last name (String) Person's id number Person's date of birth (Date) public String toString(): This method method...

  • You are asked to define a user-defined data type for students, that will contain the following...

    You are asked to define a user-defined data type for students, that will contain the following information about a student: ID number, first name, last name, major, GPA. Your structure should be cal Student. Based on the defined structure, user name on the command line, show how you will use a loop to search for the given name within the array of 5 students. use an array to record information about 5 students. Then, given a Write a C program...

  • please use java do what u can 1. Modify the Student class presented to you as...

    please use java do what u can 1. Modify the Student class presented to you as follows. Each student object should also contain the scores for three tests. Provide a constructor that sets all instance values based on parameter values. Overload the constructor such that each test score is assumed to be initially zero. Provide a method called set Test Score that accepts two parameters: the test number (1 through 3) and the score. Also provide a method called get...

  • 1-Suppose you write an application in which one class contains code that keeps track of the...

    1-Suppose you write an application in which one class contains code that keeps track of the state of a board game, a separate class sets up a GUI to display the board, and a CSS is used to control the stylistic details of the GUI (for example, the color of the board.) This is an example of a.Duck Typing b.Separation of Concerns c.Functional Programming d.Polymorphism e.Enumerated Values 2-JUnit assertions should be designed so that they a.Fail (ie, are false) if...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT