Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The first is Saleman. It has an additional instance variable that contains the a

ID: 3536923 • Letter: T

Question

The first is Saleman. It has an additional instance variable that contains the annual sales in whole dollars for that salesman. It should have the same two methods:


1.    A constructor that allows the name, monthly salary and annual sales to be initialized.


2.    An overridden method annualSalary that returns the salary for a whole year. The salary for a saleman consists of the base salary computed from the monthly salary plus a commission. The commission is computed as 2% of that salesman's annual sales up to a maximum of $20,000.


I need this in Java.

Explanation / Answer

public class Salesman extends Employee {

// declaring the variable

private int annualSales;

public int getAnnualSales()

//getter method

{

return annualSales;

}


public void setAnnualSales(int annualSales)

//setter method

{

this.annualSales = annualSales;

}

// 1. your constructor

public Salesman(String employeeName, int monthlySalary, int annualSales) {

super(employeeName, monthlySalary);

this.annualSales = annualSales;

}

//2. second method

public int annualSalary (int monthlySalary)

{

int annual = monthlySalary * 12;

// compute the total salary of 12 months first.

// if the salesman has sold good for less than 20000, then compute 2% of annualsales and add to

//annual value

if (annualSales <= 20000)

{

annual= annual + (int) (0.02 *annualSales);

}

// if salesman has sold goods of more than 20000, then as 20000 is the limit. find 2% of 20000

// and add it to the annual value

else {

annual+= annual +(int) (0.02 * 20000);

}

return annual;

}


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote