1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

can anyone hlep me

Discussion in 'Java' started by chasey, Jul 23, 2006.

  1. chasey

    chasey New Member

    Joined:
    Jul 23, 2006
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    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
    
     
  2. chasey

    chasey New Member

    Joined:
    Jul 23, 2006
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    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
    
    
    
     
  3. Amit Dave

    Amit Dave New Member

    Joined:
    Jul 24, 2006
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  4. chasey

    chasey New Member

    Joined:
    Jul 23, 2006
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    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
    
    
     
  5. Amit Dave

    Amit Dave New Member

    Joined:
    Jul 24, 2006
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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:
    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
     
  6. chasey

    chasey New Member

    Joined:
    Jul 23, 2006
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    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: Jul 25, 2006
  7. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    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.
     
  8. chasey

    chasey New Member

    Joined:
    Jul 23, 2006
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  9. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    Then create the object of the Employee class and invoke the methods you want to test
     
  10. chasey

    chasey New Member

    Joined:
    Jul 23, 2006
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  11. Amit Dave

    Amit Dave New Member

    Joined:
    Jul 24, 2006
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hi Chasey,

    It is very difficult to tell you how to test EasyIn class without knowing what it contains.
    Kindly tell us in details what all methods it have, whether they are static or not and what they do.
    Or at least give the code of EasyIn class so that we could help you properly to solve your query.

    Regards
    Amit Dave
     
  12. chasey

    chasey New Member

    Joined:
    Jul 23, 2006
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    here the info on easy in class


    Class EasyIn
    java.lang.Object
    |
    +--uwejava.EasyIn

    --------------------------------------------------------------------------------

    public abstract class EasyIn
    extends java.lang.Object

    This class contains easy to use input methods as described in the the text book "Java - The First Semester" by Quentin Charatan and Aaron Kan.

    For convenience, the class has been moved into the "uwejava" package, so you must put the following line at the start of every program that uses it:
    import uwejava.*;

    Note that you must not/cannot create any objects of this class, so a typical method call has the form:
    String s = EasyIn.getString ();



    --------------------------------------------------------------------------------

    Constructor Summary
    protected EasyIn()
    Note that you can't create any objects of this class and so it is not necessary to use the constructor
    Method Summary
    static byte getByte()
    Read a small number from the keyboard and return it as a byte (8 bit) value.
    static char getChar()
    Read a single character from the keyboard and return it as a char value.
    static double getDouble()
    Read a floating point number number from the keyboard and return it as a double value.
    static float getFloat()
    Read a floating point number number from the keyboard and return it as a float value.
    static int getInt()
    Read a number from the keyboard and return it as an int value
    static long getLong()
    Read a number from the keyboard and return it as a long integer (64 bit) value.
    static short getShort()
    Read a number from the keyboard and return it as a short integer (16 bit) value.
    static java.lang.String getString()
    Get a complete line of input from the keyboard and return it as a String value.
    static void pause()
    Wait until the user presses [return]
    static void pause(java.lang.String messageIn)
    Write the specified message and wait until the user presses [return]
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait


    Constructor Detail


    EasyIn
    protected EasyIn()Note that you can't create any objects of this class and so it is not necessary to use the constructor

    Method Detail

    getString
    public static java.lang.String getString()Get a complete line of input from the keyboard and return it as a String value.

    Example call:

    String str = EasyIn.getString ();


    --------------------------------------------------------------------------------

    getInt
    public static int getInt()Read a number from the keyboard and return it as an int value

    Example call:

    int i = EasyIn.getInt ();


    --------------------------------------------------------------------------------

    getByte
    public static byte getByte()Read a small number from the keyboard and return it as a byte (8 bit) value.

    Note that this method is not recommended for general use by novice programmers. In most cases, getInt () is preferred

    Example call:

    byte b = EasyIn.getByte ();


    --------------------------------------------------------------------------------

    getShort
    public static short getShort()Read a number from the keyboard and return it as a short integer (16 bit) value.

    Note that this method is not recommended for general use by novice programmers. In most cases, getInt () is preferred

    Example call:

    short s = EasyIn.getShort ();


    --------------------------------------------------------------------------------

    getLong
    public static long getLong()Read a number from the keyboard and return it as a long integer (64 bit) value.

    Note that this method is not recommended for general use by novice programmers. In most cases, getInt () is preferred

    Example call:

    long l = EasyIn.getLong ();


    --------------------------------------------------------------------------------

    getDouble
    public static double getDouble()Read a floating point number number from the keyboard and return it as a double value.

    Example call:

    double d = EasyIn.getDouble ();


    --------------------------------------------------------------------------------

    getFloat
    public static float getFloat()Read a floating point number number from the keyboard and return it as a float value.

    Note that this method is not recommended for general use by novice programmers. In most cases, getDouble () is preferred

    Example call:

    float f = EasyIn.getFloat ();


    --------------------------------------------------------------------------------

    getChar
    public static char getChar()Read a single character from the keyboard and return it as a char value.

    Example call:

    char ch = EasyIn.getChar ();


    --------------------------------------------------------------------------------

    pause
    public static void pause()Wait until the user presses [return]

    If you put a call to this method as the final statement of your main () method, then the program window will remain open until you enter [return]

    Example call:

    EasyIn.pause ();


    --------------------------------------------------------------------------------

    pause
    public static void pause(java.lang.String messageIn)Write the specified message and wait until the user presses [return]

    If you put a call to this method as the final statement of your main () method, then the program window will remain open until you enter [return]

    Example call:

    EasyIn.pause ("Press RETURN to continue");
     

Share This Page