Write a class that accepts a user's hourly rate of pay and the number of hours worked.
Display the user's gross pay (gross pay = hours worked * hourly rate),
the tax withheld (tax withheld = gross pay * tax rate) and the net pay
(net pay = gross pay - tax withheld).Use a named constant for storing the tax rate of

Edited by Jjaus: Code Help

4 Years
Discussion Span
Last Post by Jjaus

what have you started on this....Can you post your code?
Sometimes, when I get a problem like this I will start with the system.out.print(); and get it started in the main class, I will then explore creating a class to do the same.


Im new to Java - so i dont really know all that much heres there code :

import java.util.Scanner;

    class Tutorial
    public static void main(String[] args);

    Scanner kb = new Scanner(sysem.in);

    double = hourlyrate;
    double = hoursworked;
    double = grosspay;
    double = netpay;
    double = taxrate 0.15;
    double = taxwithheld;

    System.out.println("Please enter rate of pay?" );
    hourlyrate = kb.nextdouble();

    System.out.println("Hours Worked?" );
    hoursworked = kb.nextdouble();

    System.out.println("Gross pay:" )+(grosspay = hoursworked*hourlyrate);

    System.out.println("Tax Withheld:" )+(taxwithheld= grosspay*taxrate);

    System.out.println("netpay:" )+(netpay= Grosspay-taxwithheld);


Solved - i just realised my 'variable = ' part, and use of parentheses is incorrect: plus minor errors :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.