can anyone hlep me

chasey's Avatar, Join Date: Jul 2006
Light Poster
im really new to progeramming java im trying to do the following
"SalesStaff inherits from Employee and represents an employee who has a basic yearly salary, paid weekly over 52 weeks, but who can also earn a weekly bonus depending on performance during the weekThe employee is awarded bonus points for the week and each bonus point earns £20 extra on the weekly pay for that week only"

i just tired the following code ,
Code:
private double bonusPoints (){
return super inputSalary / 52.0 + bonusPoints * 20;
}
but it comes up with the following errors
Code:
SalesStaff.java:13: '.' expected
return super inputSalary / 52.0 + bonusPoints * 20;
             ^
SalesStaff.java:13: <identifier> expected
return super inputSalary / 52.0 + bonusPoints * 20;
                                                  ^
2 errors
chasey's Avatar, Join Date: Jul 2006
Light Poster
this is the code for all the class

Code:
public class SalesStaff extends Employee {
//instance variables
double bonusPoints;
//constructor
public SalesStaff (String inputName, String inputSurname, String inputPayRef, double inputSalary,String inputCar)
{
super (inputName , inputSurname , inputPayRef ,inputSalary);

}

//other methods
private double bonusPoints (){
return super inputSalary / 52.0 + bonusPoints * 20;
}


public void showDetails(){
 super.showDetails();
}

}//End of class definition
Amit Dave's Avatar
Newbie Member
hi chasey,

I guess you forgot a . (dot) after super keyword in this line :

return super inputSalary / 52.0 + bonusPoints * 20;


just replace the above line with this :

return super.inputSalary / 52.0 + bonusPoints * 20;

This will solve your purpose,
you can send the code for Employee class also if there are any further issues.

Thanks and Regards
Amit Dave
chasey's Avatar, Join Date: Jul 2006
Light Poster
i just tried

Code:
private double bonusPoints (){
return super.getSalary / 52.0 + bonusPoints * 20;
}
but it come up with the following error

Code:
SalesStaff.java:13: cannot resolve symbol
symbol  : variable getSalary  
location: class Employee
return super.getSalary / 52.0 + bonusPoints * 20;
                ^
i aslo tired this
Code:
return this.getSalary / 52.0 + bonusPoints * 20;
}
but this came up with following errror
Code:
SalesStaff.java:13: cannot resolve symbol
symbol  : variable getSalary  
location: class SalesStaff
return this.getSalary / 52.0 + bonusPoints * 20;
       ^
im very new to java please help

here is the emplyee classs
Code:
public class Employee {
 //instance variables
 private String fName;
 private String sName;
 private String payReference;
 private double annualSalary;
 //constructor
 public Employee (String inputName, String inputSurname, String inputPayRef, double inputSalary)
 {
 fName = inputName; 
 sName = inputSurname; 
 payReference = inputPayRef; 
 annualSalary = inputSalary;
 }
 //The next 4 methods are ACCESSOR methods 
 public String getfName(){
 return fName;
 }
 public String getsName(){
 return sName;
 }
 
 public String getPayReference(){
 return payReference;
 }
 public double getSalary(){
 return annualSalary;
 }
 //The next 4 methods are SETTING methods 
 public void setName(String newName){
 fName = newName;
 }
 public void setsName(String newsName){
 sName = newsName;
 }
 public void setPayReference(String newPayRef){
 payReference = newPayRef;
 }
 public void setSalary(double newSalary){
 annualSalary = newSalary;
 }
 
 public void showDetails(){
 System.out.println("Employee Name     : " + this.getfName()  );
 System.out.println("Employee Surname     : " + this.getsName()  );
 System.out.println("Pay Reference         : " + this.getPayReference());
 System.out.println("Annual Salary         : £ " + this.getSalary());
 }
 
 }//End of class definition
Amit Dave's Avatar
Newbie Member
Hi

Just copy this code below in a java file and name it "SalesStaff.java" and try to compile it.
It will compile successfully as it did for me.
Code: JAVA
class Employee {
    //instance variables
    private String fName;
    private String sName;
    private String payReference;
    private double annualSalary;
    //constructor
    public Employee (String inputName, String inputSurname, String inputPayRef, double inputSalary)
    {
        fName = inputName;
        sName = inputSurname;
        payReference = inputPayRef;
        annualSalary = inputSalary;
    }
    //The next 4 methods are ACCESSOR methods
    public String getfName(){
        return fName;
    }
    public String getsName(){
        return sName;
    }
   
    public String getPayReference(){
        return payReference;
    }
    public double getSalary(){
        return annualSalary;
    }
    //The next 4 methods are SETTING methods
    public void setName(String newName){
        fName = newName;
    }
    public void setsName(String newsName){
        sName = newsName;
    }
    public void setPayReference(String newPayRef){
        payReference = newPayRef;
    }
    public void setSalary(double newSalary){
        annualSalary = newSalary;
    }
   
    public void showDetails(){
        System.out.println("Employee Name     : " + this.getfName()  );
        System.out.println("Employee Surname     : " + this.getsName()  );
        System.out.println("Pay Reference         : " + this.getPayReference());
        System.out.println("Annual Salary         : £ " + this.getSalary());
    }
   
}//End of class definition




public class SalesStaff extends Employee {
    //instance variables
    double bonusPoints;
    //constructor
    public SalesStaff (String inputName, String inputSurname, String inputPayRef, double inputSalary,String inputCar)
    {
        super (inputName , inputSurname , inputPayRef ,inputSalary);
       
    }
   
    //other methods
    private double bonusPoints (){
        return super.getSalary() / 52.0 + bonusPoints * 20;
    }
   
   
    public void showDetails(){
        super.showDetails();
    }
   
}//End of class definition
 
Regards
Amit Dave
chasey's Avatar, Join Date: Jul 2006
Light Poster
this is what i have so far on a test class can someone help with it , is there a way of of test all the the class in test? im never done one before

Code:
public class EmpolyeeTestClass
{
   public static void main(String[] args)
   {
     
	  
	 }
}

Last edited by chasey; 25Jul2006 at 15:49..
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Can you explain a bit more about your test routine. The code you have is just what is the minimum needed to start the execution.
chasey's Avatar, Join Date: Jul 2006
Light Poster
hi i want to test the emplyee class , i want to test the setting of the names and to see if they work, then i want to test the other class
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Then create the object of the Employee class and invoke the methods you want to test
chasey's Avatar, Join Date: Jul 2006
Light Poster
this is what i have done can help me finish it?
Code:
public class EmpolyeeTestClass
{
   public static void main(String[] args)
   {
     System.out.println ("Please type the emplyee name:");
String fname = EasyIn.getString( );
System.out.println ("Please type the cemplyee secound name :");
String sName = EasyIn.getString( );

	  
	 }
}
the easy in is a class that i got with the cd that came with the book , can you help show the details i put e.g emplyee name