How would you calculate in Java, within the code below, the tax of how many hours an
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 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.
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill