I am new to java programming and as part of my web development course I am learning java programming.
As a exercise I had to create a income tax calculation program and so far i have only created it to calculate tax and wish to add in to the program the calculation of prsi and usc charges aswell as the calculation of income tax. I have chopped around with the program but nothing is working.
this is my program so far working as is:
import java.util.Scanner;
class Apples {
private static Scanner scan;
public static void main (String args[]) {
double gross=0,net=0,tax=0;
double singleAllowence = 10000;
double coupleAllowence = 20000;
double rateLow = .20;
double rateHigh = .41;
double cutOff = 32800;
boolean single=false;
scan = new Scanner(System.in);
System.out.println("What is your income?");
gross = scan.nextDouble();
System.out.println("Enter 1 if you are single or 2 if you are a couple");
int answer = scan.nextInt();
if (answer == 1) {
single = true;
}
else if (answer == 2) {
single = false;
}
//if income from anyone below allowence, set tax to 0
if ((single && gross <= singleAllowence) ||
(!single) && gross <coupleAllowence) {
tax = 0;
}
//calculate tax for singles where incomes below and above cutOff point
else if (single && gross < cutOff) {
tax = (gross-singleAllowence)*rateLow;
}
else if (single && gross >= cutOff) {
tax = ((cutOff-singleAllowence)*rateLow) +
((gross-cutOff)*rateHigh);
}
//calculate tax for couples where income is below or above cutOff
else if (!single && gross < cutOff) {
tax = (gross-coupleAllowence)*rateLow;
}
else if (!single && gross >= cutOff) {
tax = ((cutOff-coupleAllowence)*rateLow) +
((gross-cutOff)*rateHigh);
}
//Finally, show tax and net income to user
net = gross-tax;
System.out.println("Tax Paid: €"+tax);
System.out.println("Net Income after Tax Paid: €"+net);
}
}