Please use java for the following!! Write a program that reads the following inf
ID: 3670038 • Letter: P
Question
Please use java for the following!!
Write a program that reads the
following information and prints a payroll statement:
Employee’s name (e.g., Smith)
Number of hours worked in a week (e.g., 10)
Hourly pay rate (e.g., 9.75)
Federal tax withholding rate (e.g., 20%)
State tax withholding rate (e.g., 9%)
A sample run is shown below:
Enter employee's name: Smith
Enter number of hours worked in a week: 10
Enter hourly pay rate: 9.75
Enter federal tax withholding rate: 0.20
Enter state tax withholding rate: 0.09
Employee Name: Smith
Hours Worked: 10.0
Pay Rate: $9.75
Gross Pay: $97.5
Deductions:
Federal Withholding (20.0%): $19.5
State Withholding (9.0%): $8.77
Total Deduction: $28.27
Net Pay: $69.22
Explanation / Answer
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner in = new Scanner(System.in);
System.out.print("Enter employee's name:");
String name = in.nextLine();
System.out.print("Enter number of hours worked in a week:");
int hrs = in.nextInt();
System.out.print("Enter hourly pay rate:");
float hrs_rate = in.nextFloat();
System.out.print("Enter federal tax withholding rate:");
float fed_rate = in.nextFloat();
System.out.print("Enter state tax withholding rate:");
float state_rate = in.nextFloat();
System.out.println(" Employee Name:"+name);
System.out.println("Hours Worked:"+hrs);
System.out.println("Pay Rate:$"+hrs_rate);
System.out.println("Gross Pay:$"+(hrs_rate*hrs));
System.out.print("Deductions: ");
System.out.println("Federal Withholding ("+(fed_rate*100)+"%):$"+(hrs_rate*hrs*fed_rate));
System.out.println("State Withholding ("+(state_rate*100)+"%):$"+(hrs_rate*hrs*state_rate));
System.out.println("Total Deduction:$"+((hrs_rate*hrs*fed_rate)+(hrs_rate*hrs*state_rate)));
System.out.println("Net Pay:$"+((hrs_rate*hrs)-(hrs_rate*hrs*fed_rate)-(hrs_rate*hrs*state_rate)));
}
}