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
0.15

Recommended Answers

All 4 Replies

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);

    }
}

what problem are u encountering/?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.