Advertisement
PadmaJS

Exercise 2.25

Sep 29th, 2022
1,221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 1.40 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Exercise2_25 {
  4.   public static void main(String[] args) {
  5.     Scanner sc = new Scanner(System.in);
  6.     System.out.print("Enter employee's name: ");
  7.     String name = sc.nextLine();
  8.     System.out.print("Enter number of hours worked in a week: ");
  9.     double hours = sc.nextDouble();
  10.     System.out.print("Enter hourly pay rate: ");
  11.     double hourlyRate = sc.nextDouble();
  12.     System.out.print("Enter federal tax withholding rate: ");
  13.     double federalTaxRate = sc.nextDouble();
  14.     System.out.print("Enter state tax withholding rate: ");
  15.     double stateTaxRate = sc.nextDouble();
  16.     double totalIncome = hourlyRate * hours;
  17.     double federalTax = totalIncome * federalTaxRate;
  18.     double stateTax = totalIncome * stateTaxRate;
  19.     double netIncome = totalIncome - federalTax - stateTax;
  20.     System.out.println("Employee Name: " + name);
  21.     System.out.println("Hours Worked:\t" + hours);
  22.     System.out.println("Pay Rate:\t$" + hourlyRate);
  23.     System.out.println("Gross Pay:\t$" + totalIncome);
  24.     System.out.println("Deductions:");
  25.     System.out.println(" Federal Withholding (" + (federalTaxRate * 100) + "):\t$" + federalTax);
  26.     System.out.println(" State Withholding (" + (stateTaxRate * 100) + "):\t$" + stateTax);
  27.     System.out.println(" Total Deduction:\t$" + (stateTax + federalTax));
  28.     System.out.println("Net Pay:\t$" + netIncome);
  29.   }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement