Create a payroll program named CalcPay that allows the user to enter two double
ID: 3666538 • Letter: C
Question
Create a payroll program named CalcPay that allows the user to enter two double valuesand a string namely hours worked, hourly rate and name. After the user enters the rate, hours,and name the program should calculate the gross pay. Compute federal withholding tax which is subtracted from gross based on the following table: Hints: (100pts) Use methods as deemed appropriate. 0 to 99.99 6% 100.00 to 299.99 12% 300.00 to 599.99 18% 600.00 and up 21%. Create an ouput file named '"Payout" The file should include: Name, hours, rate, deduct, gross and net. You should also display the same using printf.
Explanation / Answer
Given data contains two programs. i provided first program code for calculate the gross pay.
Java program code:
//Header file for Scanner class
import java.util.Scanner;
//CalcPay.java
public class CalcPay
{
public static void main(String[] args)
{
//allows the user to enter two double values
//and a string namely hours worked, hourly rate and name.
double hours, rate, grossPay;
String name;
//Scanner class's object input for read input
Scanner input = new Scanner(System.in);
//Read input from the keyboard
System.out.print("Enter Name: ");
name = input.nextLine();
System.out.print("Enter number of working hours:");
hours = input.nextDouble();
System.out.print("Enter hourly rate:");
rate = input.nextDouble();
//Compute gross pay
grossPay = hours*rate;
//Display result
System.out.printf("%s Gross pay is %.2f for %.2f working hours at $%.2f hourly rate ", name, grossPay, hours, rate);
}
}
Result output:
Enter Name: Satish
Enter number of working hours:9
Enter hourly rate:1500
Satish Gross pay is 13500.00 for 9.00 working hours at $1500.00 hourly rate
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.