You appear to be a bit confused about the keyword super
.
In the code
Salariedpluscommision sp=new Salariedpluscommision();
sp.super();//error that super should be in first line but then where can i define sp
sp.super.load();//cannot find symbol sp
sp.load();
sp.getEarnings();
the compiler is telling you that super cannot be used where you're using it.
Most likely you just don't need it at all in the driver
code and the code
Salariedpluscommision sp=new Salariedpluscommision();
sp.load();
sp.getEarnings();
will do what you thought you needed these calls for.
Similarly, in the earlier code, you can likely just delete the line
h.super.load();// error cannot find symbol h
As it's coded however, you might need to call some superclass methods from your subclasses, which is what the keyword is for.
In Hourly
and likely the other subclasses, you probably want to call the Employee
load
method within the subclass load
method:
void load(){
super.load();
System.out.println("Enter hourly pay");
hpay = in.nextInt();
System.out.println("Enter no. of hours worked last week");
hours = in.nextInt();
}
which appears to be what you were trying for with some of the non-compiling code in driver
.