When the method Increase Sales is called then the method calculateWeeklyPay is c
ID: 662378 • Letter: W
Question
When the method Increase Sales is called then the method calculateWeeklyPay is called nothing is being outputted; from the main method, why?
import employee.Employee;
public class CommissionEmployee extends Employee
{
private double sales;
private double rate;
public CommissionEmployee(String fn, String ln, char m, char g, int en, boolean ft, double rate)
{
super(fn, ln, m, g, en, ft);
this.rate=rate;
this.sales=sales;
if(sales<0){
System.out.println("Error cannot increase by a negative number");
}else
sales+=sales*rate;
}
public void increaseSales(double s)
{
if(sales<0){
System.out.println("Error cannot increase by a negative number");
}else
sales+=sales*rate;
}
public double calculateWeeklyPay()
{
sales=sales*rate;
return sales;
Explanation / Answer
Change the line sales=sales*rate; to sales=sales + (sales*rate);
or sales+=sales*rate; inside the method calculate weekly pay
And then you will get the desired result.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.