Knowee
Questions
Features
Study Tools

abstract public class Employee {11.  protected abstract double getSalesAmount();12.  public double getCommision() {13.  return getSalesAmount() * 0.15;14.  }15.  }16.  class Sales extends Employee {17. 18.  }

Question

abstract public class Employee {11.  protected abstract double getSalesAmount();12.  public double getCommision() {13.  return getSalesAmount() * 0.15;14.  }15.  }16.  class Sales extends Employee {17. 18.  }

🧐 Not the exact question you are looking for?Go ask a question

Solution

It seems like you want to implement the getSalesAmount() method in the Sales class which extends the Employee abstract class. Here is how you can do it:

abstract public class Employee {
    protected abstract double getSalesAmount();

    public double getCommision() {
        return getSalesAmount() * 0.15;
    }
}

class Sales extends Employee {
    private double salesAmount;

    public Sales(double salesAmount) {
        this.salesAmount = salesAmount;
    }

    @Override
    protected double getSalesAmount() {
        return this.salesAmount;
    }
}

In this code, I've added a salesAmount field to the Sales class, along with a constructor to initialize it. The getSalesAmount() method in the Sales class returns the value of salesAmount. The @Override annotation indicates that this method is overriding the abstract method in the Employee class.

This problem has been solved

Similar Questions

10.  abstract public class Employee {11.  protected abstract double getSalesAmount();12.  public double getCommision() {13.  return getSalesAmount() * 0.15;14.  }15.  }16.  class Sales extends Employee {17. 18.  }Which method, inserted at line 17, correctly complete the Sales class?

Observe the below code.  You have a class InsurancePolicy and another class VehicleInsurancePolicy that inherits InsurancePolicy.InsurancePolicy.javapublic class InsurancePolicy { private int policyNumber; private String holderName; private double amount; double calculateBonusAmount(){ //some logic return 0; } }VehicleInsurancePolicy.javaclass VehicleInsurancePolicy extends InsurancePolicy { private String vehicleNumber; private int noOfMonths;   double calculateBonusAmount(){ //some logic return 0; }}Which access specifier can be given to the overridden method calculateBonusAmount.

Given:1. public class Employee {2. String name;3. double baseSalary;4. Employee(String name, double baseSalary) {5. this.name = name;6. this.baseSalary = baseSalary;7. }8. }And:11. public class Salesperson extends Employee {12. double commission;13. public Salesperson(String name, double baseSalary,14. double commission) {15. // insert code here16. }17. } Which code, inserted at line 17, completes the Salesperson constructor?Select one:a.this.commission = commission;b.this.commission = commission;super();c.this.commission = commission;super(name, baseSalary);d.super();commission = commission;e.super();this.commission =commission;f.super(name, baseSalary);this.commission = commission;

Define a class Employee. Display the personal salary details of three employeesusing single inheritance

Create a Java  base class called Employee. Use this class to store two double-type values that could be used to compute the salary of employees. Also,the base class should have a static variable ‘totalemp’  to keep track of the total number of employees created. Derive two specific classes called part_time and full_time from the base employee. Add a member function called as get_basic() to get the basic pay and another member called display_salary() to compute and display the salary of the employees. Using these three classes, design a program that will accept the basic pay of part_time and full_time employees interactively. Remember the two values given as input will be treated as the basic pay of the employees and the following information is used for calculating the salaries of both the part-time as well as full-time employees. Print invalid if the basic_salary of part-time employee and basic_salary of full-time employee are not met the ”Boundary Condition”Part time                                         Full timeHRA = 20% of basic pay                    HRA = 30% of basic payDA = 72% of basic pay                      DA = 80% of basic paySalary = Basic + HRA + DA              Salary = Basic + HRA + DABoundary Condition:0 < basic_salary of part-time employee <= 10000000 < basic_salary of full-time employee <= 1000000Input Format:First line to enter the basic_salary of part-time employee and basic_salary of full-time employeeOutput Format:Total salary of part-time employee and total salary of full-time employee.Total number of employees processed Sample Testcase Input-1:50007000000Sample Testcase Output-1:8900.0invalid1 Sample Testcase Input-2:30000600000Sample Testcase Output-2:42720.0110400.02 Sample Testcase Input-3:0900000Sample Testcase Output-3:invalid216000.01

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.