what i was trying to say is that a workwer pay has to be calculated by the number of hours work multiplied by the rate of pay plus teaching allowance. all workers receive $325.00 for every hr work and a health surcharge of 33.50 plus NIS plus an income tax of 5% of their gpay are deduction how do you calculated that in java
double netsal, incometax = 0;
double numhrswrk=0, rate_of_pay = 0;
double gpay, gross_sal, deduction = 0, overtime ;
System.out.println("What is your id number");
String idnum = readin.next();
System.out.println("What is your first name");
String firstname = readin.next();
System.out.println("What is your last name");
String lastname = readin.next();
System.out.println("How many hours have you worked");
double hrswrk = readin.nextDouble();
System.out.println("How much is your teaching allowance");
double teachallow = readin.nextDouble();
System.out.println("What is the amount of your NIS payment");
double nis = readin.nextDouble();
gpay = (numhrswrk * rate_of_pay) + teachallow + 325.00;
double healthsurcharge = 33.50 + nis;
incometax =(gpay * 0.5);
overtime = hrswrk + 325.00;
netsal = (gpay - deduction);
System.out.println("the lecturer id number is " + idnum);
System.out.println("the lecturer name is " + firstname + "\t" + lastname);
System.out.println("the hours worked are " + numhrswrk);
System.out.println("the income tax is " + incometax);
System.out.println("total deduction is " + deduction);
System.out.println("the gross pay is $: " + gpay);
System.out.println("the netpay is $: " + netsal);
here is the output
What is your id number
What is your first name
What is your last name
How many hours have you worked
How much is your teaching allowance
What is the amount of your NIS payment
the lecturer id number is R6800G
the lecturer name is randy george
the hours worked are 0.0 ( also why i am not seeing the total hours calculated
the income tax is 2462.5
total deduction is 0.0 (why am i not seeing the total deduction here which is supposed to calculated.
the gross pay is $: 4925.0
the netpay is $: 4925.0
BUILD SUCCESSFUL (total time: 44 seconds)
am doing something wrong here, I debug it, look thru it with a fine teeth comb still cyah see what i am missing, which i do know,
i have added them back again and still getting the same result. the hours is not calculated neither the total deduction. which am supposed to get the required calculation, so it is obvious something is missing, or my calculation is wrong somewhere
Well, yes. Your calcs are a bit of a mess to be honest.
Start by tidying up your variables. For example - the user's input goes into hrswrk, but in the calculation you use numhrswrk (which is still zero).
Declare one variable for each item in the calculation, and just use those.
Then as you go through the calc, print every result as you calculate it, so you can see what you are calculating and how well tht's working.
thank james i get that part to work but now it is only the deduction part am still getting the zero, I tried removing the zero in the variables, and I get a syntax error stating that it might not be initialized.
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...