Question

In: Computer Science

Java Coding Part A Create a class Employee. Employees have a name.   Also give Employee a...

Java Coding

Part A

Create a class Employee. Employees have a name.   Also give Employee a method paycheck() which returns a double. For basic employees, paycheck is always 0 (they just get health insurance). Give the class a parameterized constructor that takes the name;

Add a method reportDeposit. This method prints a report for the employee with the original amount of the paycheck, the amount taken out for taxes (we will do a flat 17%), and the final amount (for basic employees this will just be a lot of 0's but make sure to do the math based on what paycheck returns).  

Salaried employees are employed either for 10 or 12 months of the year for some salary. Their paycheck is their salary, divided up into two pays a month for however many months they are employed.

Using inheritance, create a class for this type of employee (more will be added in part B). Don't override reportDeposit. Give a parameterized constructor for name and salary that chains back to the parameterized superclass constructor.

In a main, create an array of employees, and set it up with some of each kind, some with different values. (hint: you've got parameterized constructors...) Loop through the list and call reportDeposit for each employee, also find the employee with the highest paycheck.

Part B  

Hourly employees have an hourly wage, and a number of hours they are scheduled to work per week,. One paycheck is based on two weeks of work (they are guaranteed to have the same hours for both weeks). They are paid an extra 5% of their hourly rate for each hour over 40 hours per week they are scheduled.

Adjunct employees may teach up to 18 credits, and are paid $827 per credit, with the total spread across 2 paychecks a month for 4 months.

Add classes for these types of employee.

Add two hourly and two adjunct employees to your array in main. You shouldn't have to change anything else in main.

Solutions

Expert Solution

PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE, IF YOU NEED ANY MODIFICATION THEN LET ME KNOW, I WILL DO IT FOR YOU

import java.util.*;
import java.util.Scanner;

class Employee {
  String name;

  Employee(String a) {
    name = a;
  }

  double paycheck() {
    return 0;
  }

  void reportDeposit() {
    double taxes = 0.17 * paycheck();
    System.out.printf("Original amount of paycheck: %.2f\n", paycheck());
    System.out.printf("Amount deducted in taxes: %.2f\n", taxes);
    System.out.printf("Final amount: %.2f\n", paycheck() - taxes);
  }
}

class Salaried extends Employee {
  double salary;

  Salaried(String name, double s) {
    super(name);
    salary = s;
  }

  @Override
  double paycheck() {
    return salary;
  }
}

class Hourly extends Employee {
  double wage;
  int hours;

  Hourly(String name, double w, int h) {
    super(name);
    wage = w;
    hours = h;
  }

  @Override
  double paycheck() {
    double pc = 2 * hours * wage;
    double bonus = 0;
    if (hours > 40) {
      bonus = 2 * (hours - 40) * (wage + 0.05 * wage);
    }
    return pc + bonus;
  }
}

class Adjunct extends Employee {
  int credits;

  Adjunct(String name, int c) {
    super(name);
    credits = c;
  }

  @Override
  double paycheck() {
    return 827 * credits;
  }
}

class MyClass {

  public static void main(String[] args) {
    Employee[] arr = new Employee[4];
    arr[0] = new Employee("abc");
    arr[1] = new Salaried("xyz", 400);
    arr[2] = new Hourly("pqr", 40, 45);
    arr[3] = new Adjunct("ijk", 16);
    for (int i = 0; i < arr.length; i++) {
      arr[i].reportDeposit();
    }
  }
}

Related Solutions

Part C (25 pts) Coding question Create a Java class name Store_XXXXX with last 5 digits...
Part C (25 pts) Coding question Create a Java class name Store_XXXXX with last 5 digits of your student ID and write your code in there. A PC store sells many types of computers. The PC can have either 16 or 8 gigabytes of memory. The quality of the PCs can be either New, Refurbished, or Dented. The price list is given as follows: Memory size/Status New Refurbished Dented 16 gigabytes 849.99 729.99 609.99 8 gigabytes 699.99 579.99 439.99 Determine...
create a java class with name ModernArt: For the first part of the assignment, you will...
create a java class with name ModernArt: For the first part of the assignment, you will be extending the JApplet class and creating a work of modern using the Graphics class to draw various shapes to the applet window. As part of your masterpiece, you should incorporate the following elements: At least 1 non-solid rectangle At least 1 non-solid oval At least 1 solid oval At least 1 non-solid Polygon At least 1 solid Polygon At least 3 lines At...
in Java, Create a class called EMPLOYEE that includes three instance variables – a first name...
in Java, Create a class called EMPLOYEE that includes three instance variables – a first name (type String), a last name (type String) and a monthly salary (double). Provide a constructor that initializes the three instance variables. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its value. Write a test app names EmployeeTest that demonstrates class EMLOYEE’s capabilities. Create two EMPLOYEE objects and display each object’s yearly...
Create a Class with Data Fields and Methods in Java. Provide a Java coding solution for...
Create a Class with Data Fields and Methods in Java. Provide a Java coding solution for the following: 1. Name the class SalonServices 2. Add private data fields: a. salonServiceDescription – This field is a String type b. price - This field is a double type 3. Create two methods that will set the field values. a. The first method setSalonServiceDescription() accepts a String parameter defined as service and assigns it to the salonServiceDescription. The method is not static b....
JAVA PROGRAMMING Part 1 Create a class Student, with attributes id, first name, last name. (All...
JAVA PROGRAMMING Part 1 Create a class Student, with attributes id, first name, last name. (All the attributes must be String) Create a constructor that accepts first name and last name to create a student object. Create appropriate getters and setters Create another class StudentOperationClient, that contains a main program. This is the place where the student objects are created and other activities are performed. In the main program, create student objects, with the following first and last names. Chris...
Java Coding Background You will create a Java class that simulates a water holding tank. The...
Java Coding Background You will create a Java class that simulates a water holding tank. The holding tank can hold volumes of water (measured in gallons) that range from 0 (empty) up to a maximum. If more than the maximum capacity is added to the holding tank, an overflow valve causes the excess to be dumped into the sewer system. Assignment The class will be named HoldingTank. The class attributes will consist of two int fields – current and maxCapacity....
Java Coding Background You will create a Java class that simulates a water holding tank. The...
Java Coding Background You will create a Java class that simulates a water holding tank. The holding tank can hold volumes of water (measured in gallons) that range from 0 (empty) up to a maximum. If more than the maximum capacity is added to the holding tank, an overflow valve causes the excess to be dumped into the sewer system. Assignment The class will be named HoldingTank. The class attributes will consist of two int fields – current and maxCapacity....
JAVA CODING PLEASE Create a class SportsCar that inherits from the Car class (CAR CLASS LISTED...
JAVA CODING PLEASE Create a class SportsCar that inherits from the Car class (CAR CLASS LISTED BELOW THIS QUESTION). Include the following: A variable Roof that holds the type of roof (Ex: Convertible, Hard-Top, Soft-Top) A variable Doors that holds the car’s number of doors (Ex: 2, 4) Implement the ChangeSpeed method to add 20 to the speed each time it is called. Add exception handling to the ChangeSpeed method to keep the speed under 65. Implement the sound method...
Trying to create a Class of Employees that holds every Employee created from a class called...
Trying to create a Class of Employees that holds every Employee created from a class called Employee in c++
Create a class Employee. Your Employee class should include the following attributes: First name (string) Last...
Create a class Employee. Your Employee class should include the following attributes: First name (string) Last name (string) Employee id (string) Employee home street address (string) Employee home city (string) Employee home state (string) Write a constructor to initialize the above Employee attributes. Create another class HourlyEmployee that inherits from the Employee class.   HourEmployee must use the inherited parent class variables and add in HourlyRate and HoursWorked. Your HourEmployee class should contain a constructor that calls the constructor from the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT