Question: How would you calculate in Java, within the code below, the tax of how many hours an employee worked, and how much they get paid

How would you calculate in Java, within the code below, the tax of how many hours an employee worked, and how much they get paid per hour?

Heres the code I have so far:

import java.util.Scanner;

public class PDA { //personal digital assistant (another name for calculator) public static void main(String[] args) { final double incomeTax = 0.09; final double socialSecurityTax = 8.75; double pay, netPay; double hours, payPerHour;

Scanner sc = new Scanner(System.in); //user input System.out.println("Enter your firstname: "); String employeeFirstName = sc.nextLine();

System.out.println("Enter your lastname: "); String employeeLastName = sc.nextLine();

System.out.println("Enter your pay per hour: "); payPerHour = sc.nextDouble();

System.out.println("Enter hours worked: "); hours = sc.nextDouble();

pay = payPerHour * hours; //calculating the employee's net pay netPay = pay - (pay * (incomeTax/ 100.0) - (pay * (socialSecurityTax / 100.0))); System.out.println(" Employee: " + employeeLastName + ", " + employeeFirstName); //output System.out.println("*******************************"); System.out.printf("Gross Pay: $%.2f ", pay); System.out.printf("Taxes: tIncome Tax: $" + incomeTax); System.out.printf(" tSS tax: $" + socialSecurityTax); System.out.println(" *******************************"); System.out.printf("Net Pay: $%.2f ", netPay); } }

I have the output the way it should be just not the tax column since it's not supposed to output just 0.09 and 8.75, but the actual calculation.

Step by Step Solution

3.41 Rating (164 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Answer Then you can output these calculated tax amounts Heres how you can modify your code to achiev... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!