The variable gross is still 0 after I gave it another number. Manager is a subclass of Employee and computePay is abstract. The gross in the toString method is 0. I tried to do gross = (pay/24); in the toString method of manager and it worked, but I need to put that in computePay and have it work there.
import java.util.Scanner; import java.io.*; import java.util.ArrayList; public abstract class Employee { protected String name; protected double grossPay; protected double netPay; protected String job; public Employee(String person, String title) { name = person; job = title; } abstract public void computePay(); public void computeTax() { } public String toString() { String s = "s"; return s; } }
public class Manager extends Employee implements Bonus { private String title; private double pay; private double gross; public Manager(String name, String title, String dprtmt, double salary) { super(name, title); gross = 0; pay = salary; } public double calcBonus() { return gross*0.01; } public void computePay() { gross = (pay/24); } public String toString() { String s = name + " title: " + job + " Pay: "+ Double.toString(pay) + " Gross: " +Double.toString(gross); return s; } }