## glamourhits -4

Everything is correct, no errors! I dont know How to implement the (20.0%) and the (9.0%) in the Deductions area.[/b] 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 Payrolls
{
public static void main(String []args)
{

Scanner input = new Scanner(System.in);

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

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

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

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

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

System.out.print("Employee Name: ");
String EmpName = input.next();

System.out.println("Hours Worked:" + hoursWorked);

System.out.println("Pay Rate:" + payRate);

double grossPay;
grossPay = payRate * hoursWorked;

System.out.println("Gross Pay:" + grossPay);

double deductions;
deductions = grossPay * fedTax;

System.out.println("\tDeductions:");
System.out.println("\t\tFederal Witholding %: \$" +  deductions);

double statTax;
statTax = grossPay * stateTax;

System.out.println("\t\tState Witholding %: \$" +  statTax);

double totalDeduction;
totalDeduction = deductions + statTax;

System.out.println("\t\tTotal Deduction: \$" + totalDeduction);

double netPay;
netPay = grossPay - totalDeduction;

System.out.println("Net Pay:" + netPay);
}
}``````

can any 1 fix it and post it here thank you very very much

## NormR1 563

How to implement the (20.0%) and the (9.0%) in the Deductions area

Do you have the formula for computing those values?

no

## NormR1 563

Then you need to find one so you can write the code to produce the required answer.

## glamourhits -4

``````import java.util.Scanner;

public class Payrolls
{
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: ");
String employeeName = input.next();

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

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

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

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

System.out.print("Employee Name: ");
String EmpName = input.next();

System.out.println("Hours Worked:" + hoursWorked);

System.out.println("Pay Rate:" + payRate);

double grossPay;
grossPay = payRate * hoursWorked;

System.out.println("Gross Pay:" + grossPay);

double deductions;
deductions = grossPay * fedTax;

System.out.println("\tDeductions:");
System.out.println("\t\tFederal Witholding %: \$" +  deductions);

double statTax;
statTax = grossPay * stateTax;

System.out.println("\t\tState Witholding %: \$" +  statTax);

double totalDeduction;
totalDeduction = deductions + statTax;

System.out.println("\t\tTotal Deduction: \$" + totalDeduction);

double netPay;
netPay = grossPay - totalDeduction;

System.out.println("Net Pay:" + netPay);
}
}``````

## NormR1 563

Is the problem solved?

## glamourhits -4

nop here is the Question ... http://i56.tinypic.com/2r7woqg.png

please if u can fix it and post it here .. thank You

commented: This is not a homework completion service. -3

## NormR1 563

If you have a question you should post the question here.

## JamesCherrill 3,661

Have you run your program? In what exact way does its output differ from the output you expect? The calculations for deductions seem to be present and sensible (lines 51-62)

## glamourhits -4

i am getting errors on

``double fedTax = input.nextDouble();``

and

``double stateTax = input.nextDouble();``

## NormR1 563

If you'd post the full text of the error messages, we could help.

## JamesCherrill 3,661

"errors" doesn't tell anyone much, does it? Java carefully gives you very detailed error messages. If you share them with us we can help more. So:
What input are you entering for those lines and EXACTLY and COMPLETELY what "errors" do you get?

## glamourhits -4

sorry ..here after i put the value for - Enter hourly pay rate: .. it shows this message

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - fedTax is already defined in main(java.lang.String[])
at payrolls.Payrolls.main(Payrolls.java:33)
Enter federal tax withholding rate: Java Result: 1

## NormR1 563

Do you understand what "is already defined" means?
Do you know how to define a variable? Have you defined a variable more than once?
You are only allowed to define a variable one time in the same scope.
You can use it as much as you want, but you can only define it once.

## glamourhits -4

well i am very new at this .. here is the program i have to create .

http://i56.tinypic.com/2r7woqg.png ---> please go here to view the image of my program..

and so far as u can see this is what i have

``````import java.util.Scanner;

public class Payrolls
{
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: ");
String employeeName = input.next();

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

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

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

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

System.out.print("Employee Name: ");
String EmpName = input.next();

System.out.println("Hours Worked:" + hoursWorked);

System.out.println("Pay Rate:" + payRate);

double grossPay;
grossPay = payRate * hoursWorked;

System.out.println("Gross Pay:" + grossPay);

double deductions;
deductions = grossPay * fedTax;

System.out.println("\tDeductions:");
System.out.println("\t\tFederal Witholding %: \$" +  deductions);

double statTax;
statTax = grossPay * stateTax;

System.out.println("\t\tState Witholding %: \$" +  statTax);

double totalDeduction;
totalDeduction = deductions + statTax;

System.out.println("\t\tTotal Deduction: \$" + totalDeduction);

double netPay;
netPay = grossPay - totalDeduction;

System.out.println("Net Pay:" + netPay);
}
}``````

and now i totally lost .. so if there any way .
some one can do it and post it here ..
thank you very much for ur help ..

## Ezzaral 2,714

You completely ignored NormR1's questions and this is the third time you have posted up the link to the assignment and asked someone to do it for you.

You can either put some effort into this or I can just close the thread so you don't waste any more of other peoples' valuable time.

## NormR1 563

You need to get an understanding of how a compiler and a computer work and how to do simple arithmetic.
I suggest that you give up on this program and start over with a very simple program
that reads in two numbers from the user, and computes the sum, product and difference for the two numbers and prints out the results.

## glamourhits -4

ok thankxx i will try it ... i just wanted this program to run .. thankx all for replying so fast.