An hourly employee is paid at a rate of 125 per hour,from the workers gross pay,12% withheld for income tax,and 15 withheld for union dues. If the worker has 2 of more dependents additional 120 for health insurance. Write a java program that will input the total deduction,basic salary,gross pay and net pay.
Civil Status SSS Insurance
Single 9% of grosspay
Married 6% of grosspay
Head of the family 8% of grosspay

as of now,here i have done. but it has an error. pls help me!

``````import javax.swing.*;
class totalDeduction{
public static void main(String[]args){
String w,stat,dpen,t;
int cstat,hw,ud;
double gpay,npay,td,tax,dp,sss,siS,siM,sD,siH;
w=JOptionPane.showInputDialog(new JFrame(),"Enter Hours Worked:");
hw=Integer.parseInt(w);
td=(ud+tax);
JOptionPane.showMessageDialog(null,"Your Total Deduction is "+ td);
gpay=hw*125;
ud=15;
JOptionPane.showMessageDialog(null,"Your Gross Pay is "+ gpay);
tax=(gpay*.12);
siS=gpay*.09;
siM=gpay*.06;
siH=gpay*.08;
stat=JOptionPane.showInputDialog(new JFrame(),"Enter Civil Status: \nchoose \n[1]SINGLE \n[2]MARRIED \n[3]HEAD OF THE FAMILY");
cstat=Integer.parseInt(stat);
dpen=JOptionPane.showInputDialog(new JFrame(),"How many dependents?");
dp=Double.parseDouble(dpen);
if (dp>=2){
gpay=(siM+120);
if (cstat==1){
JOptionPane.showMessageDialog(null,"Your Gross Pay is " +siS);
}else if (cstat==2){
JOptionPane.showMessageDialog(null,"Your Gross Pay is " +siM);
}else if (cstat==3){
JOptionPane.showMessageDialog(null,"Your Gross Pay is " +siH);

System.exit(0);
}
}
}
}``````

Initialize 'ud' and 'tax' to zero.

it has an error

What is the error?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.