Created
October 24, 2013 12:50
-
-
Save joeyv/7136641 to your computer and use it in GitHub Desktop.
Calculates your tax cost
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
| import java.util.Scanner; | |
| import java.text.*; | |
| public class Tax { | |
| public static void main(String[] args) | |
| { | |
| // Declare variables | |
| int allowedDeduction = 10000, deduction = 2000; | |
| int grossIncome, dependents; | |
| double taxRate = 0.2; | |
| double finalIncome; | |
| // Scan in input for income and dependents | |
| Scanner scan = new Scanner(System.in); | |
| grossIncome = scan.nextInt(); | |
| dependents = scan.nextInt(); | |
| // Calculate tax | |
| dependents = dependents * deduction; // every dependant is worth 2k | |
| finalIncome = ((grossIncome - dependents) - allowedDeduction) * taxRate; // minus dependents and the 10k allowed tax, then multiply by the 2% tax rate | |
| // money format | |
| NumberFormat nf = NumberFormat.getCurrencyInstance(); | |
| // print out | |
| System.out.println("\nIncome: " + nf.format(finalIncome)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment