Created
May 4, 2013 05:42
-
-
Save jimmy087/5516348 to your computer and use it in GitHub Desktop.
Simple program which calculates tax and net pay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Exercise1 { | |
| public static void main(String[] args) { | |
| java.util.Scanner input = new java.util.Scanner(System.in); | |
| System.out.print("Enter employee name: "); | |
| String employeeName = input.nextLine(); | |
| System.out.println("Number of hours worked: "); | |
| int numberOfHoursWorked = input.nextInt(); | |
| System.out.println("Hourly wage rate: "); | |
| double wageRate = input.nextDouble(); | |
| System.out.println("Enter the Federal tax rate: "); | |
| double federalTaxRate = input.nextDouble(); | |
| System.out.println("Enter the state tax rate: "); | |
| double stateTaxRate = input.nextDouble(); | |
| double grossPay = wageRate * numberOfHoursWorked; | |
| double federalTax = grossPay * federalTaxRate; | |
| double stateTax = grossPay * stateTaxRate; | |
| double netPay = grossPay - federalTax - stateTax; | |
| System.out.println("Deduction of " + employeeName); | |
| System.out.println("Federal Tax: " + federalTax); | |
| System.out.println("State Tax: " + stateTax); | |
| System.out.println("Net Pay: " + netPay); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment