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 2 of 2

Thread: Compute federal personal income tax of U.s of 2009

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Compute federal personal income tax of U.s of 2009

    The Problem is :
    The United States federal personal income tax is calculated based on filing status and taxable
    income. There are four filing statuses: single filers, married filing jointly, married filing separately,
    and head of household. The tax rates vary every year. Table 3.2 shows the rates for
    2009. If you are, say, single with a taxable income of $10,000, the first $8,350 is taxed at 10%
    and the other $1,650 is taxed at 15%. So, your tax is $1,082.5
    You are to write a java program to compute personal income tax. Your program should prompt
    the user to enter the filing status and taxable income and compute the tax. Enter 0 for single
    filers, 1 for married filing jointly, 2 for married filing separately, and 3 for head of household.
    Your program computes the tax for the taxable income based on the filing status. The filing
    status can be determined using if statements outlined as follows:
    if (status == 0) {
    // Compute tax for single filers
    }
    else if (status == 1) {
    // Compute tax for married filing jointly
    }
    else if (status == 2) {
    // Compute tax for married filing separately
    }
    else if (status == 3) {
    // Compute tax for head of household
    }
    else {
    // Display wrong status
    }
    For each filing status there are six tax rates. Each rate is applied to a certain amount of taxable
    income. For example, of a taxable income of $400,000 for single filers, $8,350 is taxed at
    10%, (33,950 - 8,3502) at 15%, (82,250 - 33,950), at 25%(171,550 - 82,250) at 28%, (372,950 - 171,550) at 33%, (400,000 - 372,950)and at 35%.



    The Code I did is incomplete,My ques is : what I did for single filers..should i have to do it again for ramining three types of filers?



     
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package assignment3tanhaislam;
    import javax.swing.JOptionPane;
    /**
     *
     * @author Trisa
     */
    public class Assignment3TanhaIslam {
     
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
    Scanner input = newScanner(System.in);
    promt 
            int status = input.nextint();
    PromtIncome
            int status = input.nextint();
     
     // Prompt the user to enter filing status
     String statusString = JOptionPane.showInputDialog(
     "Enter the filing status:\n" +
     "(0-single filer, 1-married jointly,\n" +
     "2-married separately, 3-head of household)");
     int status = input.nextInt();
     
     // Prompt the user to enter taxable income
     String incomeString = JOptionPane.showInputDialog(
     "Enter the taxable income:");
     double income = input.nextDouble();
     
     // Compute tax
     
    if(status==0)
     { // Compute tax for single filers
     if (income <= 8350)
     tax = income * 0.10;
     else if (income <= 33950)
     tax = 8350 * 0.10 + (income - 8350) * 0.15;
     else if (income <= 82250)
     tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (income - 33950) * 0.25;
     else if (income <= 171550)
     tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (income - 82250) * 0.28;
     else if (income <= 372950)
     tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
     (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 +
     (income - 171550) * 0.33;
     else
     tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + (372950 - 171550) * 0.33 + (income - 372950) * 0.35;
     }
    else if(status==1)
     { // Compute tax for married file jointly
     // Left as exercise
     }
    else if (status == 2)
     { // Compute tax for married separately
     // Left as exercise
     }
    else if (status==3)
     { // Compute tax for head of household
     // Left as exercise
     }
    else
    {
     
     System.out.println("Error: invalid status");
     
     }
     
     // Display the result
     JOptionPane.showMessageDialog(null, "Tax is " + (int)(tax * 100) / 100.0);
     }
     }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,310
    Thanks
    56
    Thanked 2,373 Times in 2,344 Posts

    Default Re: Compute federal personal income tax of U.s of 2009

    should i have to do it again for ramining three types of filers?
    Can the tables be put into arrays and accessed using the status?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Family Income Project
    By kassim05 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: February 7th, 2012, 07:18 AM
  2. help with tax program???
    By JavaNewb3 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 31st, 2011, 01:34 PM
  3. First, simple, two-classed tax program
    By rousseau in forum What's Wrong With My Code?
    Replies: 5
    Last Post: May 24th, 2011, 03:14 PM
  4. Calculate federal taxes program! Help!
    By ocmjt in forum What's Wrong With My Code?
    Replies: 13
    Last Post: March 11th, 2010, 11:25 AM

Tags for this Thread