Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

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

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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);
    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);
    }
    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default 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.

  3. #3
    Junior Member
    Join Date
    Jan 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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:
    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);
    }
    }

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default 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.

Similar Threads

  1. Compute federal personal income tax of U.s of 2009
    By pink.devil.tanha in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 7th, 2013, 07:42 AM
  2. Why wont my program calculate sales tax?
    By scholaryoshi in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 28th, 2012, 08:30 PM
  3. help with tax program???
    By JavaNewb3 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 31st, 2011, 12:34 PM
  4. First, simple, two-classed tax program
    By rousseau in forum What's Wrong With My Code?
    Replies: 5
    Last Post: May 24th, 2011, 02:14 PM
  5. tax return program..help finish please!!
    By dscrudato21xo in forum Loops & Control Statements
    Replies: 2
    Last Post: November 5th, 2009, 03:23 PM