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

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.

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