hi james/anyone/stultuske
I am again trying and practicing my java. I am doing this payroll program which include doing methods and array and have no idea where I have gone wrong again
i have debug it but inno me, cant find the error and it is there somewhere anyway here is the program. I am not finish coding am only testing out the program after each block of code just to see how it is running
double gsalary = 0;
double rateofpay = 0;
int usercode = 0;
if (usercode == 1) {
gsalary = (575 * hrswrk) + 2500;
} else if (usercode == 2) {
gsalary = (325 * hrswrk) + 1250;
}
return gsalary;
}
public static double calRegwrkrs(double hrswrk, double fsalary) {
double doubletme = 0, rateofpay = 0, gsalary =0;
if (hrswrk == 160) {
gsalary = fsalary;
} else if (hrswrk < 160) {
rateofpay = (fsalary - 160);
gsalary = hrswrk * rateofpay;
} else if (hrswrk > 160) {
doubletme = (hrswrk - 160)* 2 *(fsalary/260);
gsalary = fsalary + doubletme;
}
return gsalary;
}
public static double calDeduction( double gsalary){
double incometax = 0.25, hsurcharge1 = 33.00, hsurcharge2 = 19.20;
double totaldeduct = 0, totalgsalary;
incometax = (gsalary * 0.25/100);
if(gsalary > 499.99)
{
totaldeduct = hsurcharge1 ;
}
else if(gsalary > 499.99 && gsalary <5000)
{
gsalary = hsurcharge2;
totalgsalary = (gsalary - 5000)* 0.25 + 33.00;
}
return totaldeduct;
}
public static double calNsalary(double totaldeduction, double gsalary){
double nsalary, totaldeduct = 0;
nsalary = (gsalary - totaldeduct);
return nsalary;
}
public static void main(String[] args) {
Scanner userinput = new Scanner(System.in);
char usercode = 0;
String codeStr = null;
char code = 0;
int numofwrkrs = 0;
int masterdegree = 1, bachelor = 2, empqualicode;
String empnum = null, reg_wrkrs, lecturer = null, qualification_code;
int i;
double hrswrked, rate_of_pay, fixed_salary, totalgross_sal = 0, countreg = 0, count_lecturer = 0;
double highestgpay = 0, lowestgpay = 0;
String firstnme[] = new String[numofwrkrs];
String lastnme[] = new String[numofwrkrs];
char empcode[] = new char[numofwrkrs];
double gsalary[] = new double[numofwrkrs];
double nsalary[] = new double[numofwrkrs];
for (i = 1; i < numofwrkrs; i++) {
System.out.println("please enter the employees name ");
firstnme[i] = userinput.next();
System.out.println("please enter the employees last name");
lastnme[i] = userinput.next();
System.out.println("please enter the employee code");
empcode[i] = codeStr.charAt(0);
}
here is the output which is nothing. I dont know what I have put in or declare wrong and as i said am not finish coding
run:
BUILD SUCCESSFUL (total time: 0 seconds)