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
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.
Nice first post. Hope you have a good time with that program that the OP said doesn't work that was written years ago.