I am having some difficulty, any advice would be gladly appreciated. Thanks in advance.

Write a program that reads the following information and prints a payroll statement:

Employee's name
Number of hours worked in a week
Hourly pay rate
Federal tax withholding rate
State tax withholding rate

Enter employee's name: Smith
Enter hours: 10
Enter hourly pay rate: 6.75 <-----Obtain input
Enter federal tax withholding rate: 0.20
Enter state tax withholding rate: 0.09
Employee name: Smith

Hours Worked: 10.0
Pay Rate: $6.75
Gross Pay: $67.5
Deductions:
Federal Withholding (20.0%): $13.5 <----Display output
State Withholding (9.0%): $6.07
Total Deduction: $19.57
Net Pay: $47.92

import java.util.Scanner;
 
public class Payroll
{
   public static void main (String []args)
   {
       String name;
       int hours;
       double rate;
       double fedTax;
       double stateTax;
 
 
       Scanner input = new Scanner(System.in);
 
       System.out.print("Enter employee name: ");
 
 
       System.out.print("Enter number of hours worked in a week: ");
 
 
       System.out.print("Enter hourly pay rate: ");
 
 
       System.out.print("Enter federal tax withholding rate: ");
 
 
       System.out.print("Enter state tax withholding rate: ");
 
       System.out.println("Employee Name: " + string)
 
 
       double grossPay;
 
       grossPay = rate * hours;
 
       double fedwithHolding;
 
       fedwithHolding = fedTax * grossPay;
 
       double statewithHolding;
 
       statewithHolding = stateTax * grossPay;  
 
       double deduction;
 
       deduction = fedwithHolding + statewithHolding;
 
 
 
 
 
       double netPay;
 
       netPay = (grossPay) - deduction;
 
 
 
       System.out.println("The netpay is " +netPay);
       }
}

You forgot to mention what difficulties???

,but this seems to be obvious. You do not know how to use Scanner ! ! !
So take your time and read API reference for Scanner http://java.sun.com/javase/6/docs/api/java/util/Scanner.html and do it. Methods like nextLine(), nextInt() or nextDouble() can be your friends...
But consider that user enter wrong data what then? Are you supposed to take care of it or so far user is expected only to enter corrcet data.

PS: Other which may have temptentation to give him quick solution. Please don't do it! shivers20 needs to do it on his own. And there is no problem to provide additional info if he/she show interest, also all what he need is in advice above

If you need help with this program please contact me at [email address removed]

Can you please help since I have a program like yours but I have to make it in 2 different windows{i.e. 2 different class} but i have to do it using arrays....and I don't now how I can do it... Can you pls help me....

I am having some difficulty, any advice would be gladly appreciated. Thanks in advance.

Write a program that reads the following information and prints a payroll statement:

Employee's name
Number of hours worked in a week
Hourly pay rate
Federal tax withholding rate
State tax withholding rate

Enter employee's name: Smith
Enter hours: 10
Enter hourly pay rate: 6.75 <-----Obtain input
Enter federal tax withholding rate: 0.20
Enter state tax withholding rate: 0.09
Employee name: Smith

Hours Worked: 10.0
Pay Rate: $6.75
Gross Pay: $67.5
Deductions:
Federal Withholding (20.0%): $13.5 <----Display output
State Withholding (9.0%): $6.07
Total Deduction: $19.57
Net Pay: $47.92

import java.util.Scanner;
 
public class Payroll
{
   public static void main (String []args)
   {
       String name;
       int hours;
       double rate;
       double fedTax;
       double stateTax;
 
 
       Scanner input = new Scanner(System.in);
 
       System.out.print("Enter employee name: ");
 
 
       System.out.print("Enter number of hours worked in a week: ");
 
 
       System.out.print("Enter hourly pay rate: ");
 
 
       System.out.print("Enter federal tax withholding rate: ");
 
 
       System.out.print("Enter state tax withholding rate: ");
 
       System.out.println("Employee Name: " + string)
 
 
       double grossPay;
 
       grossPay = rate * hours;
 
       double fedwithHolding;
 
       fedwithHolding = fedTax * grossPay;
 
       double statewithHolding;
 
       statewithHolding = stateTax * grossPay;  
 
       double deduction;
 
       deduction = fedwithHolding + statewithHolding;
 
 
 
 
 
       double netPay;
 
       netPay = (grossPay) - deduction;
 
 
 
       System.out.println("The netpay is " +netPay);
       }
}

I am having some difficulty, any advice would be gladly appreciated. Thanks in advance.

Write a program that reads the following information and prints a payroll statement:

Employee's name
Number of hours worked in a week
Hourly pay rate
Federal tax withholding rate
State tax withholding rate

Enter employee's name: Smith
Enter hours: 10
Enter hourly pay rate: 6.75 <-----Obtain input
Enter federal tax withholding rate: 0.20
Enter state tax withholding rate: 0.09
Employee name: Smith

Hours Worked: 10.0
Pay Rate: $6.75
Gross Pay: $67.5
Deductions:
Federal Withholding (20.0%): $13.5 <----Display output
State Withholding (9.0%): $6.07
Total Deduction: $19.57
Net Pay: $47.92

import java.util.Scanner;
 
public class Payroll
{
   public static void main (String []args)
   {
       String name;
       int hours;
       double rate;
       double fedTax;
       double stateTax;
 
 
       Scanner input = new Scanner(System.in);
 
       System.out.print("Enter employee name: ");
 
 
       System.out.print("Enter number of hours worked in a week: ");
 
 
       System.out.print("Enter hourly pay rate: ");
 
 
       System.out.print("Enter federal tax withholding rate: ");
 
 
       System.out.print("Enter state tax withholding rate: ");
 
       System.out.println("Employee Name: " + string)
 
 
       double grossPay;
 
       grossPay = rate * hours;
 
       double fedwithHolding;
 
       fedwithHolding = fedTax * grossPay;
 
       double statewithHolding;
 
       statewithHolding = stateTax * grossPay;  
 
       double deduction;
 
       deduction = fedwithHolding + statewithHolding;
 
 
 
 
 
       double netPay;
 
       netPay = (grossPay) - deduction;
 
 
 
       System.out.println("The netpay is " +netPay);
       }
}

thanks a lot for the program.u r real people to work with.

commented: Abysmal fail. -2

Nice first post. Hope you have a good time with that program that the OP said doesn't work that was written years ago.

Here you go!

import java.util.Scanner;

public class Payroll
{
   public static void main (String []args)
   {
       String name;
       int hours;
       double rate;
       double fedTax;
       double stateTax;


       Scanner input = new Scanner(System.in);

       System.out.print("Enter employee name: ");
       name = input.next();

       System.out.print("Enter number of hours worked in a week: ");
       hours=input.nextInt();

       System.out.print("Enter hourly pay rate: ");
       rate=input.nextDouble();

       System.out.print("Enter federal tax withholding rate: ");
       fedTax=input.nextDouble();

       System.out.print("Enter state tax withholding rate: ");
       stateTax=input.nextDouble();


       double grossPay;
       grossPay = rate * hours;

       double fedwithHolding;
       fedwithHolding = (fedTax/100) * grossPay;

       double statewithHolding;
       statewithHolding = (stateTax/100) * grossPay;  

       double deduction;
       deduction = fedwithHolding + statewithHolding;

       double netPay;
       netPay = (grossPay) - deduction;


       System.out.println("The grosspay is $" +grossPay);
       System.out.println("The netpay is $" +netPay);
       System.out.println("Employee's name: " +name);//Employee's name  (e.g., Smith)
       System.out.println("Number of hours worked in a week: "+hours);
       System.out.println("Hourly pay rate: $"+rate);
       System.out.println("Federal tax withholding rate: "+fedTax+"%");
       System.out.println("State tax withholding rate: "+stateTax+"%");
       }
}

InsaneComputer: not only is this a bit a waste of effort (considering the original post is over 6 years old), it's also not the point of the forum to spoon-feed code. by copy pasting some code, they won't learn, it's better to help them understand what to do, so they can do it themselves.

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.