By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,587 Members | 1,101 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,587 IT Pros & Developers. It's quick & easy.

Don't know where the error

P: n/a
import javax.swing.JOptionPane;
public class AddStaff{

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

SalaryCalculation[] StaffSalary = new SalaryCalculation[2];

for (x = 0; x < 2; x++){
StaffName = JOptionPane.showInputDialog("Please enter Staff Name");
StaffCurrPosition = JOptionPane.showInputDialog("Please enter STAFF
POSITION");
Salary = JOptionPane.showInputDialog("Please enter STAFF SALARY");
StaffSalary[x] = new SalaryCalculation(StaffName,StaffCurrPosition,Sala ry);
}
StaffName = JOptionPane.showInputDialog("Please enter Manager Name");
StaffCurrPosition = JOptionPane.showInputDialog("Please enter Staff
POSITIOn");
Salary = JOptionPane.showInputDialog("Please enter Staff Salary");
SalaryCalculation Manager = new
SalaryCalculation(StaffName,StaffCurrPosition,Sala ry);

//View Staff Information;

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


}
}
public class SalaryCalculation{
String StaffName;
String CurrPosition;
String Salary;
double SalaryInDouble;
public SalaryCalculation(String StaffName,String CurrPosition,String
Salary){
StaffName = StaffName;
CurrPosition = CurrPosition;
Salary = Salary;
ToUpperCase();
SalaryConverting();
SalaryCalculation();
}

private void ToUpperCase(){
StaffName = StaffName.toUpperCase();
}

private void SalaryConverting(){
SalaryInDouble = Double.parseDouble(Salary);
}
private void SalaryCalculation(){
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

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Here is the error:
StaffName = StaffName;
CurrPosition = CurrPosition;
Salary = Salary;


Change the above code to:

this.StaffName = StaffName;
this.CurrPosition = CurrPosition;
this.Salary = Salary;

Cheerz L.
Jul 17 '05 #2

P: n/a
Nevermind.. i found the mistake..
--
"If we don't stand together than this is the end"
The Business

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.