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

Source Code in Java:

interface Employee
{
public double getPay();
}

class MonthlyEmployee implements Employee
{
private double perMonth; //instance variable to store pay per month
public void setMonthlyPay(double perMonth) //method to set pay per month
{
this.perMonth=perMonth;
}
public double getPay() //method to get pay for the Employee
{
return perMonth;
}
}

class HourlyEmployee implements Employee
{
//final variables to store constants
private final int MAX_WEEKLY_HOURS=40;
private final double OVERTIME_RATE=1.75;
private double perHour,hoursWorked; //instance variable
public void setHourlyRate(double perHour) //method to set pay her hour
{
this.perHour=perHour;
}
public void setTotalHours(double hoursWorked) //method to set hours worked
{
this.hoursWorked=hoursWorked;
}
public double getPay() //method to get pay for the Employee
{
if(hoursWorked<=MAX_WEEKLY_HOURS)
return perHour*hoursWorked;
else
return perHour*MAX_WEEKLY_HOURS+perHour*(hoursWorked-MAX_WEEKLY_HOURS)*OVERTIME_RATE;
}
}


Related Solutions

** 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...
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)...
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...
**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...
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...
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:...
write a java code program using loops to compute the sum of the 30 terms of...
write a java code program using loops to compute the sum of the 30 terms of the series below. Find sum of all integers between 100 and 200 which are divisible by 9 or 13 Write a program to find the sum of the first 8 terms of the series 1 + 11 + 111 + 1111 + . . . Output: Term Ratio Sum
Java please! Write the code in Exercise.java to meet the following problem statement: Write a program...
Java please! Write the code in Exercise.java to meet the following problem statement: Write a program that will print the number of words, characters, and letters read as input. It is guaranteed that each input will consist of at least one line, and the program should stop reading input when either the end of the file is reached or a blank line of input is provided. Words are assumed to be any non-empty blocks of text separated by spaces, and...
write JAVA code with the following condition Write the pseudocode for a new data type MyStack...
write JAVA code with the following condition Write the pseudocode for a new data type MyStack that implements a stack using the fact that you have access to a queue data structure with operations enqueue(), dequeue(), isEmpty(). Remember that every stack should have the operations push() and pop(). Hint: use two queues, one of which is the main one and one is temporary. Please note that you won’t be able to implement both push() and pop() in constant time. One...
JAVA I need to write a code that calculates mean and standard deviation using arrays and...
JAVA I need to write a code that calculates mean and standard deviation using arrays and OOP. This is what I have so far. I'm close but my deviation calculator method is throwing errors. Thanks so much :) import java.util.Scanner; import java.util.Arrays; public class STDMeanArray { private double[] tenUserNums = new double[10];//Initialize an array with ten index' private double mean; private double deviation; Scanner input = new Scanner(System.in);//create new scanner object /*//constructor public STDMeanArray(double tenUserNum [], double mean, double deviation){...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT