I am having trouble understanding exactly what I am supposed to do with the following instructions.
a. Create a class named Pay that includes variables of type double that hold rate of pay per hour and withholding rate percent. Gross pay is computed as hours worked times rate of pay per hour. Net pay is calculated as gross pay minus (gross pay times withholding rate). For example, if the withholding rate is 25% and gross pay is $100, then net pay would be $100 - (100 * .25).
b. Create two overloaded methods named computeNetPay(), each of these methods will take different parameters and will calculate net pay based . These methods are to return the calculated value which will be displayed by the caller.
c. When computeNetPay receives one arguments (hours worked), calculate net pay as described in step A.
d. When computeNetPay() receives two arguments (hours worked and bonus amount), calculate gross pay as in step A, add the bonus amount to the gross pay, and then calculate the net pay by applying the withholding against the gross pay.
e. Write a main() method that instantiates the class and calls both of the overloaded methods and displays their return values.
f. Name the file Pay.java and submit it using the WA2 link above.
I need to know if I am doing my code right or if I am doing it wrong and if so how can I fix the code and finish my project. This is only my second week learning Java and it is starting to bog me down because I don't know if I am doing it correctly.
public class Pay
{
public static void main(String[] args)
{
double hours = 20;
final double BONUS = 2.00;
computeNetPay(hours);
//computeNetPay(hours, BONUS);
}
public static void computeNetPay( double hours)
{
//double hours = 20;
double payPerHour = 5;
double withholdingTax = 0.25;
double grossPay;
double netPay;
double tax;
grossPay = hours * payPerHour;
tax = grossPay * withholdingTax;
netPay = grossPay -tax;
System.out.println(" The Gross Pay is:$" + netPay + " with no bonus pay added.");
}
//public static double computeNetPay(double hours, double BONUS)
{
//return
}
}