Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help Im stuck with this lab. I have the following.Thanks in advance class Employee{ ?String name = name; ?int id; ?Employee(String name, int id){

Please help Im stuck with this lab. I have the following.Thanks in advance
class Employee{
?String name = "name";
?int id;
?Employee(String name, int id){
??this.name = name;
??this.id = id;
?}
?public String toString() {
??return "Name: " + name + ", Id: " + id;
?}
}
class Full extends Employee{
?double salary;
public Full(){}
?public Full(String name, int id, double salary){
??super(name, id);
??this.salary = salary;
?}
?double getSalary() {
??return salary;
?}
?public String toString() {
??return super.toString() + ", Salary: " + salary;
?}
}
class Part extends Employee{
?double hours, hourlyWage;
public Part(){}
?public Part(String name, int id, double hours, double hourlyWage){
??super(name, id);
??this.hours = hours;
??this.hourlyWage = hourlyWage;
?}
?double getSalary() {
??return hours * hourlyWage;
?}
?public String toString() {
??return super.toString() + ", Hours: " + hours + ", HourlyWage: " + hourlyWage;
?}
}
public class lab7{
?public static void main(String[] args){
??Part John = new Part("John", 001, 10.0, 9.5);
??System.out.println(John.toString());
??Full Steven = new Full("Steven", 007, 50000);
??System.out.println(Steven.toString());
?}
}
image text in transcribed
Emplo -name: String id: int Employee(String name, int id) + getsalaryO: double +toString0: Strin Note: Employee is an abstract class, and getSalary is an abstract method PartTime Employee -hours: double -hourlyWage: double PartTime Employee(String name, int id, double hours, double hourlyWage) +toString0: String ....necessary methods note: salary-hours hourlyWage FullTime Emplovee -salary: double FullTime Employee(String name int id, double salary) +toString0: String necessary methods 1. Design three classes as above 2. The program should be named: xxxx Lab8.java (xxxx is your email ID) 3. Implement the necessary methods for each class 4. The test class xxxxx Lab8 should have a main) method that will call three methods a. First method will create 2 part time employee objects and 2 full time employee objects (hardcoded b. Second method will print all the employees with their name, id and salary by using toString0 c. Third method will print all the information(name, id, salary) of the employee which has the highest the values in your program), these objects should be stored in an Employee array method. salary. (Use for loop and if statements to find the employee with the highest salary.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What are the purposes of promotion ?

Answered: 1 week ago