Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Book:- Java An introdcution to problem solving and programming 7ed plz give the

ID: 3850094 • Letter: B

Question

Book:- Java An introdcution to problem solving and programming 7ed

plz give the write code in Java and make sure that the output is macthing with my prof output.

The Assignment:

      Chapter 8:

      Programming Projects 6:  This project is found starting on page 664

Assignment Guidelines:

   

For this Programming Project, start with implementations of the Person, Student, and Undergraduate classes as depicted in Figure 8.4 and the polymorphism demo in Listing 8.6. Define the Employee, Faculty, and Staff classes as depicted in Figure 8.2. The Employee class should have instance variables to store the employee ID as an int and the employee’s department as a String. The Faculty class should have an instance variable to store the faculty member’s title (e.g. "Professor of Computer Science") as a String. The Staff class should have an instance variable to store the staff member’s pay grade (a number from 1 to 20) as an int. Every class should have appropriate constructors, accessors, and mutators, along with a writeOutput method that outputs all of the instance variable values.

Modify the program in Listing 8.6 to include at least one Faculty object and at least one Staff object in addition to the Undergraduate and Student objects. Without modification to the for loop, the report should output the name, employee ID, department, and title for the Faculty objects, and the name, employee ID, department, and pay grade for the Staff objects.

Note:

1. The solution must use the class Employee2, to distinguish it from the Employee class from Practice Program 1.

2. The project must have the following classes:

     a. person, in file person.java

     b. student, in student.java

     c. underGraduate, in underGraduate.java

     d. employee2, in file employee2.java

     e. faculty, in file faculty.java

      f. staff, in staff.java

      g. polymorphismDemo, in a file polymorphismDemo.java

Figure 8.2

Figure 8.4

Figure 8.6

Sample output:

----jGRASP exec: java PolymorphismDemo
Name: Cotty, Manny
Student Number: 4910
Student Level: 1

Name: Kick, Anita
Student Number: 9931
Student Level: 2

Name: DeBanque, Robin
Student Number: 8812

Name: Bugg, June
Student Number: 9901
Student Level: 4

Name: Mock, Kenrick
Dept: Computer Science
Employee ID: 3056
Title: Professor of Computer Science

Name: Jones, James
Dept: Mathematical Sciences
Employee ID: 1551
Pay Grade: 15


----jGRASP: operation complete.

Figure 8.2

  public class Student extends Person  {      private int studentNumber;      public Student ()      {          super ();          studentNumber = 0; //Indicating no number yet      }          public Student (String initialName, int initialStudentNumber)      {          super (initialName);          studentNumber = initialStudentNumber;      }          public void reset (String newName, int newStudentNumber)      {          setName (newName);          studentNumber = newStudentNumber;      }          public int getStudentNumber ()      {          return studentNumber;      }          public void setStudentNumber (int newStudentNumber)      {          studentNumber = newStudentNumber;      }          public void writeOutput ()      {          System.out.println ("Name: " + getName ());          System.out.println ("Student Number: " + studentNumber);      }          public boolean equals (Student otherStudent)      {          return this.hasSameName (otherStudent) &&              (this.studentNumber == otherStudent.studentNumber);      }  }  

Explanation / Answer

public class Student extends Person

{

private int studentNumber;

public Student ()

{

super ();

studentNumber = 0;

}

public Student (String initialName, int initialStudentNumber)

{

super (initialName);

studentNumber = initialStudentNumber;

}

public void reset (String newName, int newStudentNumber)

{

setName (newName);

studentNumber = newStudentNumber;

}

public int getStudentNumber ()

{

return studentNumber;

}

public void setStudentNumber (int newStudentNumber)

{

studentNumber = newStudentNumber;

}

public void writeOutput ()

{

System.out.println ("Name: " + getName ());

System.out.println ("Student Number: " + studentNumber);

}

public boolean equals (Student otherStudent)

{

return this.hasSameName (otherStudent) &&

(this.studentNumber == otherStudent.studentNumber);

}

}

public class Undergraduate extends Student

{

private int level;

public Undergraduate ()

{

super ();

level = 1;

}

public Undergraduate (String initialName,

int initialStudentNumber, int initialLevel)

{

super (initialName, initialStudentNumber);

setLevel (initialLevel);

}

public void reset (String newName, int newStudentNumber,

int newLevel)

{

reset (newName, newStudentNumber);

setLevel (newLevel);

}

public int getLevel ()

{

return level;

}

public void setLevel (int newLevel)

{

if ((1 <= newLevel) && (newLevel <= 4)

level = newLevel;

else

{

System.out.println ("Illegal level!");

System.exit (0);

}

}

public void writeOutput ()

{

super.writeOutput ();

System.out.println ("Student Level: " + level);

}

public class PolymorphismDemo

{

public static void main(String[] args)

{

Person[] people = new Person[4];

people[0] = new Undergraduate("Cotty, Manny", 4910, 1);

people[1] = new Undergraduate("Kick, Anita", 9931, 2);

people[2] = new Student("DeBanque, Robin", 8812);

people[3] = new Undergraduate("Bugg, June", 9901, 4);

for (Person p : people)

{

p.writeOutput();

System.out.println();

}

}

}

public boolean equals (Undergraduate otherUndergraduate)

{

return equals ((Student) otherUndergraduate) &&

(this.level == otherUndergraduate.level);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote