Don't know where the error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • IHateSuperman

    Don't know where the error

    import javax.swing.JOp tionPane;
    public class AddStaff{

    public static void main(String args[]){
    String StaffName;
    String StaffCurrPositi on;
    String Salary;
    String SalaryInDouble;
    int x;

    SalaryCalculati on[] StaffSalary = new SalaryCalculati on[2];

    for (x = 0; x < 2; x++){
    StaffName = JOptionPane.sho wInputDialog("P lease enter Staff Name");
    StaffCurrPositi on = JOptionPane.sho wInputDialog("P lease enter STAFF
    POSITION");
    Salary = JOptionPane.sho wInputDialog("P lease enter STAFF SALARY");
    StaffSalary[x] = new SalaryCalculati on(StaffName,St affCurrPosition ,Salary);
    }
    StaffName = JOptionPane.sho wInputDialog("P lease enter Manager Name");
    StaffCurrPositi on = JOptionPane.sho wInputDialog("P lease enter Staff
    POSITIOn");
    Salary = JOptionPane.sho wInputDialog("P lease enter Staff Salary");
    SalaryCalculati on Manager = new
    SalaryCalculati on(StaffName,St affCurrPosition ,Salary);

    //View Staff Information;

    StaffName = StaffSalary[0].ReturnStaffNam e(); //<< the error




    }
    }


    public class SalaryCalculati on{
    String StaffName;
    String CurrPosition;
    String Salary;
    double SalaryInDouble;
    public SalaryCalculati on(String StaffName,Strin g CurrPosition,St ring
    Salary){
    StaffName = StaffName;
    CurrPosition = CurrPosition;
    Salary = Salary;
    ToUpperCase();
    SalaryConvertin g();
    SalaryCalculati on();
    }

    private void ToUpperCase(){
    StaffName = StaffName.toUpp erCase();
    }

    private void SalaryConvertin g(){
    SalaryInDouble = Double.parseDou ble(Salary);
    }
    private void SalaryCalculati on(){
    SalaryInDouble = SalaryInDouble * 5 / 100;
    }

    public double ReturnSalary(){
    return SalaryInDouble;

    }
    public String ReturnStaffName (){
    return StaffName;
    }
    public String ReturnPosition( ){
    return CurrPosition;
    }

    }


    i try to fix the error for damn long hours.. still can't fix it..

    --
    "If we don't stand together than this is the end"
    The Business

  • Pipo

    #2
    Re: Don't know where the error


    Here is the error:[color=blue]
    > StaffName = StaffName;
    > CurrPosition = CurrPosition;
    > Salary = Salary;[/color]

    Change the above code to:

    this.StaffName = StaffName;
    this.CurrPositi on = CurrPosition;
    this.Salary = Salary;

    Cheerz L.

    Comment

    • IHateSuperman

      #3
      Re: Don't know where the error

      Nevermind.. i found the mistake..


      --
      "If we don't stand together than this is the end"
      The Business

      Comment

      Working...