Jessica Chu Jessica Chu - 4 months ago 73
Java Question

arguments in if else java questions

I have a homework problem but i'm stuck with the if..else code because I have no idea what i'm supposed to do there.

  • Write a class that has two overloaded static methods, with the same
    name, for calculating payroll for a company.

  • Use the If..Else structure

  • If Regular payroll is less than 40 hours, there are 2 arguments –
    hours worked and payrate

  • Else Overtime payroll is equal to regular hours = 40 hours,
    overtime hours = extra hours, there are 3 arguments regular hours
    worked, payrate, and overtime hours

  • The user will use the keyboard to enter the regular hours worked,

    payrate, and overtime hours - use the Scanner class.

  • The formulas for calculating the regular payroll is: hours

    payrate*hours worked

  • The formula for calculating overtime payroll is: payrate * hours
    worked + (overtime hours * 1.5)

I think i got the rest correct, but I'm kinda stuck with my if..else code because I don't know what it means by "there are 2 arguments". I understand what arguments are in Java but not in this context. here's what i have so far:

public class ifelse {

public static double calculatePayroll (double hoursPayrate, int hoursWorked)
return hoursPayrate * hoursWorked;

public static double calculatePayroll (double hoursPayrate, int hoursWorked, double overtimeHours)
return hoursPayrate * hoursWorked + (overtimeHours *1.5);

public static void main(String[] args) {
// TODO Auto-generated method stub

double hoursPayrate, overtimeHours;
int hoursWorked;

Scanner keyboard = new Scanner(;

System.out.println("Enter the hours worked");
hoursWorked = keyboard.nextInt();

System.out.print("Enter the payrate ");
hoursPayrate = keyboard.nextInt();

System.out.print("Enter the overtime hours");
overtimeHours = keyboard.nextInt();

if (hoursWorked < 40)

else (hoursWorked = 40)