Question

In: Computer Science

Using Java, write the the following code. Only the bold needs to be answered Here is...

Using Java, write the the following code. Only the bold needs to be answered

Here is the driver:

package assign

public class A3Driver {

public static void main(String[] args) {

//Test GSUStudent object

GSUStudentWorker gsw = new GSUStudentWorker("Bunny","Bugs", 2000, 9, 8, 9001234);

gsw.setGPA(3.7);

gsw.setHourlyRate(10.00);

gsw.setTotalHours(30);

System.out.println(gsw);

GSUStudentWorker gsw2 = new GSUStudentWorker("Bunny","Betty", 1999, 9, 8, 9002413);

gsw2.setGPA(4.0);

gsw2.setHourlyRate(10.00);

gsw2.setTotalHours(45);

System.out.println(gsw2);

//Test GSUStoreSupervisor

GSUStoreSupervisor gss = new GSUStoreSupervisor("Duck","Daffy", 1980, 9, 8);

gss.setMonthlyPay(4000);

System.out.println(gss);

//test GSUSuperStudent

GSUSuperStudent gsuper = new GSUSuperStudent("Mouse","Minny", 1990, 9, 8, 9004321);

gsuper.setGPA(3.9);

gsuper.setHourlyRate(10.00);

gsuper.setTotalHours(30);

gsuper.setMonthlyPay(4000);

System.out.println(gsuper);

}

}

1. The Person class
a. Person is an abstract class.

b. All class variables of the Person class must be private.

c.is a class with a single constructor, Person(String lName, String fName, int birthYear, int birthMonth, int birthDay). All arguments of the constructor should be stored as class variables. There should only be getter methods for first and last name variables. There should be no getters or setters forbirthYear, birthMonth, birthDay.

  1. The method computeAge() takes no arguments and returns the person’s computed age (as of today's date) as a string of the form "X years, Y months and Z days". Hint: Use the LocalDate and Period classes.

    i. e.g. "21 years, 2 months and 3 days". ii. e.g. "21 years and 3 days".

    iii. e.g. "21 years and 2 months". iv. e.g. "21 years".

    v. e.g. "2 months and 3 days".

  2. The toString method returns a string comprised of the results of

    getFname, getLName and computeAge. E.g.
    i. “Bunny Bugs is 19 years and 1 day old”

  3. The equals method returns true if the name and date of birth of this person and the other person are the same, otherwise return false.

2. The Employee interface
a.has a single method, getPay(), which returns a double

representing the pay earned for the period in dollars and cents.

3. The MonthlyEmployee interface
a. This interface extends the Employee interface.
b. has a single void method, setMonthlyPay(double perMonth), which

takes a double as an argument. The argument is the amount earned for the month in dollars and cents.

4. The HourlyEmployee interface
a. This interface extends the Employee interface.
b. has a void method, setHourlyRate(double perHour), which takes a

double as an argument. The argument is the amount earned for

each hour that the employee works.


c. has a void method, setTotalHours(double hoursWorked), which

takes a double as an argument. The argument is the total hours worked for the week.

  1. Has a final integer variable MAX_WEEKLY_HOURS, which is assigned

    a value of 40. This variable is used to assess if the total

    hours worked exceeds the mandated hours.

  2. Has a final double variable OVERTIME_RATE, which is assigned a

    value of 1.75. This variable is used to compute the pay amount for hours worked that exceeds the mandated hours.

5. The Student class
a. The Student class is abstract.

  1. The Student class extends the Person class.

  2. All (if any) class variables of the Student class must be private.

  3. has an abstract void method, setGPA(double gpa), which takes a double as an argument. The argument is the grade point average of the student using a 4.0 scale.

  4. has an abstract method, getGPA(), which returns a double. The returned value is the grade point average of the student using a 4.0 scale.

6. The GSUStudentWorker class
a. The GSUStudentWorker class extends the Student class and

inherits from the HourlyEmployee interface.

  1. is a class with a single constructor, GSUStudentWorker (String lName, String fName, int birthYear, int birthMonth, int birthday, int eid). There should be a getter and setter for eid, which is the Eagle ID of the student.

  2. All class variables of the Student class must be private.

  3. has a void method, setGPA(double gpa), which takes a double as an argument. The argument is the grade point average of the student using a 4.0 scale.

  4. has a method, getGPA(), which returns a double. The returned value is the grade point average of the student using a 4.0 scale.

f. Has a toString() method that returns a string in the form shown below.

i. Bugs Bunny is 19 years and 15 days old and is a Great Sauce student with a 3.7 GPA who earned $300.00 this week.

7. The GSUStoreSupervisor class
a. The GSUStoreSupervisor class extends the Person class and

inherits from the MonthlyEmployee interface.

  1. is a class with a single constructor, GSUStoreSupervisor(String lName, String fName, int birthYear, int birthMonth, int birthDay).

  2. All class variables of the Student class must be private.

  3. Has a toString() method that returns a string in the form shown below.

    i. Daffy Duck is 39 years and 15 days old and is a Great Sauce monthly employee who earned $4000.00 this period.

8. The GSUSuperStudent class
a. GSUSuperStudent has found a way to get paid as a monthly

         employee and as a student employee.
  1. The GSUSuperStudent class extends the GSUStudentWorker class and inherits from the MonthlyEmployee interface.

  2. All class variables of the Student class must be private.

  3. Has a toString() method that returns a string in the form shown below.

    i. Minny Mouse is 29 years and 15 days old and is a Great Sauce student with a 3.9 GPA who earned $4300.00 this period.

Example output:

__________Example from A3Driver shown below

Bugs Bunny is 19 years and 15 days old and is a Great Sauce student with a 3.7 GPA who earned $300.00 this week.

Betty Bunny is 20 years and 15 days old and is a Great Sauce student with a 4.0 GPA who earned $487.50 this week.

Daffy Duck is 39 years and 15 days old and is a Great Sauce monthly employee who earned $4000.00 this period.

Minny Mouse is 29 years and 15 days old and is a Great Sauce student with a 3.9 GPA who earned $4300.00 this period.

Solutions

Expert Solution

/*********************************Employee.java*******************/

package employee3;

public interface Employee {

   public double getPay();
}

/************************MonthlyEmployee.java************************/

package employee3;

public interface MonthlyEmployee extends Employee {

   public void setMonthlyPay(double perMonth);
}
/***********************************HourlyEmployee.java*********************/

package employee3;


/**
* The Interface HourlyEmployee.
*/
public interface HourlyEmployee extends Employee {

   /**
   * Sets the hourly rate.
   *
   * @param perHour the new hourly rate
   */
   public void setHourlyRate(double perHour);

   /**
   * Sets the total hours.
   *
   * @param hoursWorked the new total hours
   */
   public void setTotalHours(double hoursWorked);

   /** The max weekly hours. */
   final int MAX_WEEKLY_HOURS = 40;

   /** The overtime rate. */
   final double OVERTIME_RATE = 1.75;

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

package employee3;


/**
* The Class Student.
*/
public abstract class Student extends Person {

   /** The major. */
   private String major;

   /**
   * Instantiates a new student.
   *
   * @param id the id
   * @param name the name
   * @param major the major
   */
   public Student(String id, String name, String major) {
       super(id, name);
       this.major = major;
   }

   /**
   * Gets the major.
   *
   * @return the major
   */
   public String getMajor() {
       return major;
   }

   /**
   * Sets the major.
   *
   * @param major the new major
   */
   public void setMajor(String major) {
       this.major = major;
   }

   /**
   * Sets the gpa.
   *
   * @param gpa the new gpa
   */
   public abstract void setGPA(double gpa);

   /**
   * Gets the gpa.
   *
   * @return the gpa
   */
   public abstract double getGPA();
}
/*********************************Person.java*******************/

package employee3;

/**
* The Class Person.
*/
public class Person {

   /** The id. */
   private String id;

   /** The name. */
   private String name;

   /**
   * Instantiates a new person.
   *
   * @param id the id
   * @param name the name
   */
   public Person(String id, String name) {
       super();
       this.id = id;
       this.name = name;
   }

   /**
   * Gets the id.
   *
   * @return the id
   */
   public String getId() {
       return id;
   }

   /**
   * Sets the id.
   *
   * @param id the new id
   */
   public void setId(String id) {
       this.id = id;
   }

   /**
   * Gets the name.
   *
   * @return the name
   */
   public String getName() {
       return name;
   }

   /**
   * Sets the name.
   *
   * @param name the new name
   */
   public void setName(String name) {
       this.name = name;
   }

   /*
   * (non-Javadoc)
   *
   * @see java.lang.Object#toString()
   */
   @Override
   public String toString() {
       return id + ", " + name;
   }

}
Please let me know if you have any doubt or modify the answer, Thanks :)


Related Solutions

Using Java, write the the following code. Only the bold needs to be answered Here is...
Using Java, write the the following code. Only the bold needs to be answered Here is the driver: package assign public class A3Driver { public static void main(String[] args) { //Test GSUStudent object GSUStudentWorker gsw = new GSUStudentWorker("Bunny","Bugs", 2000, 9, 8, 9001234); gsw.setGPA(3.7); gsw.setHourlyRate(10.00); gsw.setTotalHours(30); System.out.println(gsw); GSUStudentWorker gsw2 = new GSUStudentWorker("Bunny","Betty", 1999, 9, 8, 9002413); gsw2.setGPA(4.0); gsw2.setHourlyRate(10.00); gsw2.setTotalHours(45); System.out.println(gsw2); //Test GSUStoreSupervisor GSUStoreSupervisor gss = new GSUStoreSupervisor("Duck","Daffy", 1980, 9, 8); gss.setMonthlyPay(4000); System.out.println(gss); //test GSUSuperStudent GSUSuperStudent gsuper = new GSUSuperStudent("Mouse","Minny", 1990, 9,...
Using Java, write the the following code. Only the bold needs to be answered Here is...
Using Java, write the the following code. Only the bold needs to be answered Here is the driver: package assign public class A3Driver { public static void main(String[] args) { //Test GSUStudent object GSUStudentWorker gsw = new GSUStudentWorker("Bunny","Bugs", 2000, 9, 8, 9001234); gsw.setGPA(3.7); gsw.setHourlyRate(10.00); gsw.setTotalHours(30); System.out.println(gsw); GSUStudentWorker gsw2 = new GSUStudentWorker("Bunny","Betty", 1999, 9, 8, 9002413); gsw2.setGPA(4.0); gsw2.setHourlyRate(10.00); gsw2.setTotalHours(45); System.out.println(gsw2); //Test GSUStoreSupervisor GSUStoreSupervisor gss = new GSUStoreSupervisor("Duck","Daffy", 1980, 9, 8); gss.setMonthlyPay(4000); System.out.println(gss); //test GSUSuperStudent GSUSuperStudent gsuper = new GSUSuperStudent("Mouse","Minny", 1990, 9,...
** Only bold needs to be answered In Java, implement the Athlete, Swimmer, Runner, and AthleteRoster...
** Only bold needs to be answered In Java, implement the Athlete, Swimmer, Runner, and AthleteRoster classes below. Each class must be in separate file. Draw an UML diagram with the inheritance relationship of the classes. 1. The Athlete class a. All class variables of the Athlete class must be private. b.is a class with a single constructor: Athlete(String lName, String fName, int birthYear, int birthMonth, int birthDay, char gender). All arguments of the constructor should be stored as class...
**only need part c and d answered below. It is in bold. In java, please implement...
**only need part c and d answered below. It is in bold. In java, please implement the classes below. Each one needs to be created. Each class must be in separate file. The expected output is also in bold. I have also attached the driver for part 4. 2. The StudentRoster class should be in the assignment package. a. There should be class variable for storing multiple students (the roster), semester and year. All class variables of the Student class...
**Only need the bold answered In Java, implement the Athlete, Swimmer, Runner, and AthleteRoster classes below....
**Only need the bold answered In Java, implement the Athlete, Swimmer, Runner, and AthleteRoster classes below. Each class must be in separate file. Draw an UML diagram with the inheritance relationship of the classes. 1. The Athlete class a. All class variables of the Athlete class must be private. b.is a class with a single constructor: Athlete(String lName, String fName, int birthYear, int birthMonth, int birthDay, char gender). All arguments of the constructor should be stored as class variables. There...
using java language only write a code Have the function StringChallenge(str) take the str string parameter...
using java language only write a code Have the function StringChallenge(str) take the str string parameter being passed and return the number of words the string contains (e.g. "Never eat shredded wheat or cake" would return 6). Words will be separated by single spaces. Examples Input: "Hello World" Output: 2 Input: "one 22 three" Output: 3 ------- you have the following code edit it to get the result mport java.util.*; import java.io.*; class Main {   public static String StringChallenge(String str)...
**Only need the bold answered Implement the Athlete, Swimmer, Runner, and AthleteRoster classes below. Each class...
**Only need the bold answered Implement the Athlete, Swimmer, Runner, and AthleteRoster classes below. Each class must be in separate file. Draw an UML diagram with the inheritance relationship of the classes. 1. The Athlete class a. All class variables of the Athlete class must be private. b.is a class with a single constructor: Athlete(String lName, String fName, int birthYear, int birthMonth, int birthDay, char gender). All arguments of the constructor should be stored as class variables. There should only...
Using existing Stack Java Collection Framework, write Java Code segment to do the following.   You may...
Using existing Stack Java Collection Framework, write Java Code segment to do the following.   You may write this in jGrasp Create a Stack of String called, myStacks Read input from keyboard, 10 names and then add to myStacks As you remove each name out, you will print the name in uppercase along with a number of characters the name has in parenthesis. (one name per line).   e.g.     Kennedy (7) Using existing Stack Java Collection Framework, write Java Code segment to...
Using the provided code (found here), write a program using the main method where the user...
Using the provided code (found here), write a program using the main method where the user enters Strings and the program echoes these strings to the console until the user enters “quit”. When user quits the program should print out, “Goodbye”. You may assume that the case is ignored when the user enters, “quit”, so “quit”, “QUIT”, “Quit”,“qUiT”, etc. are all acceptable ways to end the program. The results should be printed out to the console in the following format:...
JAVA programming - please ONLY answer prompts with java code *Inheritance* will be used in code...
JAVA programming - please ONLY answer prompts with java code *Inheritance* will be used in code Classwork A zoo is developing an educational safari game with various animals. You will write classes representing Elephants, Camels, and Moose. Part A Think through common characteristics of animals, and write a class ZooAnimal. ☑ ZooAnimal should have at least two instance variables of different types (protected), representing characteristics that all animals have values for. ☑ It should also have at least two methods...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT