Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Exercise2_25 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.print("Enter employee's name: ");
- String name = sc.nextLine();
- System.out.print("Enter number of hours worked in a week: ");
- double hours = sc.nextDouble();
- System.out.print("Enter hourly pay rate: ");
- double hourlyRate = sc.nextDouble();
- System.out.print("Enter federal tax withholding rate: ");
- double federalTaxRate = sc.nextDouble();
- System.out.print("Enter state tax withholding rate: ");
- double stateTaxRate = sc.nextDouble();
- double totalIncome = hourlyRate * hours;
- double federalTax = totalIncome * federalTaxRate;
- double stateTax = totalIncome * stateTaxRate;
- double netIncome = totalIncome - federalTax - stateTax;
- System.out.println("Employee Name: " + name);
- System.out.println("Hours Worked:\t" + hours);
- System.out.println("Pay Rate:\t$" + hourlyRate);
- System.out.println("Gross Pay:\t$" + totalIncome);
- System.out.println("Deductions:");
- System.out.println(" Federal Withholding (" + (federalTaxRate * 100) + "):\t$" + federalTax);
- System.out.println(" State Withholding (" + (stateTaxRate * 100) + "):\t$" + stateTax);
- System.out.println(" Total Deduction:\t$" + (stateTax + federalTax));
- System.out.println("Net Pay:\t$" + netIncome);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement