# help in how to add code to work with income tax calculation program

• January 21st, 2014, 07:24 AM
jayokayo69
help in how to add code to work with income tax calculation program
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);
gross = scan.nextDouble();
System.out.println("Enter 1 if you are single or 2 if you are a couple");
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);
}
}
• January 21st, 2014, 07:55 AM
GregBrannon
Re: help in how to add code to work with income tax calculation program
Welcome to the Forum! Please read this topic to learn how to post your code correctly along with other useful info for newcomers.
• January 21st, 2014, 08:11 AM
jayokayo69
Re: help in how to add code to work with income tax calculation program
Thankyou Greg. i made the change. never used forums until now so something new to learn to use...

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:
Code Java:

```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); } }```
• January 21st, 2014, 01:14 PM
GregBrannon
Re: help in how to add code to work with income tax calculation program
You're speaking Greek to many of the forum's members (like me) who don't know your tax system or the abbreviations that go along with it. I assume those items you want to calculate have formulas. Do you know them and can't code them, or do you not know them? If you don't know the formulas, we're not tax experts here, so you might be better searching web sites that can provide you with those formulas. If you have the formulas but can't program them, then show us the formulas and explain what you need help with.