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

The second subclass is Executive. It has an additional instance variable that re

ID: 3536925 • Letter: T

Question

The second subclass is Executive. It has an additional instance variable that reflects the current stock price. It should have the same two methods:


1. A constructor that allows the name, monthly salary and stock price to be initialized.


2. An overridden method annualSalary that returns the salary for a whole year. The salary for an executive consists of the base salary computed from the monthly salary plus a bonus. The bonus is $30,000 if the current stock price is greater than $50 and nothing otherwise.


I need this in Java.

Explanation / Answer


public class Executive extends Employee{


private int stockPrice;

//declaring the variable


public int getStockPrice()

//getter method

{

return stockPrice;

}


public void setStockPrice(int stockPrice)

//setter method

{

this.stockPrice = stockPrice;

}

//1. your first method- the constructor

public Executive(String employeeName, int monthlySalary, int stockPrice) {

super(employeeName, monthlySalary);

this.stockPrice = stockPrice;

}

//2. your second method

public int annualSalary(int monthlySalary)

{

int annual = monthlySalary * 12;

//calculating the yearly salary

// if the stock price is greater than 50, add a bonus of 30000 to annual

if (stockPrice > 50)

{

annual = annual + 30000;

}// if not, no bonus is added

else {

annual = annual +0;

}

return annual;

}

}