I have written the code as best that I know how but I am unsure that the questions asked are being fulfilled. Any advice to improve this code would really help me.
Question asked:
- Create a new project in NetBeans called
Payrollimplement
- Create a new class in the same project called
PayrollCal
In this class you will have four methods:
- The first method will set pay
- The second method will return the pay
- The third method will calculate take home pay (pay-tax which will be passed onto the method)
- The fourth method will calculate a bonus which is 10% int this case.
In your main class create a
PayrollCal
object and invoke your methods to ensure they work.
package payrollcal;
/**
*
* @author ace
*/
public class PayrollCal {
public static void setPay()
{
double setPay = 400;
double tax1Pay = setPay;
System.out.println("Wages are:\t"+setPay);
System.out.println("Wages + Bonus are:\t"+(returnPay(setPay)+setPay));
System.out.println("Tax Payed on salary:\t"+(TaxPay(tax1Pay)));
System.out.println("Total salary :\t"+((returnPay(setPay))+setPay+-(TaxPay(tax1Pay))));
}
public static double returnPay(double setPay)
{
return (setPay *.1);
}
public static double TaxPay(double tax1Pay)
{
double netPay = 400*.1;
double tax = netPay/.24;
double taxPay;
tax1Pay = netPay - (netPay/tax);
return (tax1Pay);
}
public static void main(String[] args)
{
setPay();
}
}
returnPay
calculates the bonus, and with it serving double duty :D sort of everything is covered by mere three methods which made one free formain
. :D I'm voting to reopen, as it's not exactly broken and can and should be reviewed. By applying a few common principles the mess can be cleaned up, so let's teach him. \$\endgroup\$