Results 1 to 4 of 4
  1. #1
    grcarr77 is offline Member
    Join Date
    Oct 2011
    Posts
    8
    Rep Power
    0

    Default New help with tax table

    I need to alter this code to accept only income between $50,000 and $60,000

    and then make code to output a screen that shows a print tax table to show all data at once can someone please help

    Here is my code so far

    Java Code:
    package financialapplication;
    
        import javax.swing.JOptionPane;
    
        public class financialapplication {
        public static void main (String [] args) {
        // Prompt the user to enter filing status
        String letters = JOptionPane.showInputDialog(
        "Enter the filing status:");
        int status = Integer.parseInt(letters);
    
        // Prompt the user to enter taxable income
        String symbol = JOptionPane.showInputDialog(
        "Enter the taxable income:");
        double income = Double.parseDouble(symbol);
    
        //Display the result
        JOptionPane.showMessageDialog(null, "Tax is " +
        (int)(computeTax(status, income) * 100) / 100.0);
    
        System.out.println("income \t\t tax ");
        System.out.println("________________________");
        System.out.println(income + "\t\t" + (int)(computeTax(status, income) * 100) / 100.0);
        }
    
    
        public static double computeTax(double income,
        int r1, int r2, int r3, int r4, int r5) {
    
        double tax = 0;
    
        if (income <= r1)
        tax = income * 0.10;
        else if (income <= r2)
        tax = r1 * 0.10 + (income - r1) * 0.15;
        else if (income <= r3)
        tax = r1 * 0.10 + (r2 - r1) * 0.15 + (income - r2) * 0.27;
        else if (income <= r4)
        tax = r1 * 0.10 + (r2 - r1) * 0.15 + (r3 - r2) * 0.27 + (income - r4) * 0.35;
        else
        tax = r1 * 0.10 + (r2 - r1) * 0.15 + (r3 - r2) * 0.27 + (r4 - r3) * 0.30 + (r5 - r4) * 0.35 + (income - r5) * 0.386;
    
        return tax;
        }
    
        public static double computeTax(int status, double income) {
        switch (status) {
        case 0: return //Compute tax for Single
        computeTax(income, 6000, 27950, 67700, 141250, 307050);
        case 1: return //Compute tax for married joint
        computeTax(income, 12000, 46700, 112850, 171950, 307050);
        case 2: return //Compute tax for married separately
        computeTax(income, 6000, 23350, 56425, 85975, 153525);
        case 3: return //Compute tax for head of a house
        computeTax(income, 10000, 37450, 96700, 156600, 307050);
        default: return 0;
        }
        }
        }
    Last edited by Eranga; 11-02-2011 at 06:03 AM.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  3. #3
    grcarr77 is offline Member
    Join Date
    Oct 2011
    Posts
    8
    Rep Power
    0

    Default Re: New help with tax table

    It runs but the output only shows income and tax I need it to show taxable income single married joint Married Separate and head of a house columns and then needs to show inputs $50000 to $60000 in $50 increments. I am absolutely stumpped on how to proceed, can you give me an example or resource to find out how to do this.

    Thanks,

    Greg

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Replies: 1
    Last Post: 09-27-2011, 07:06 AM
  2. table
    By danghieu in forum New To Java
    Replies: 1
    Last Post: 05-12-2010, 08:03 AM
  3. Copy Default table model to another default table model?
    By greatmajestics in forum AWT / Swing
    Replies: 2
    Last Post: 04-28-2010, 05:08 PM
  4. Replies: 1
    Last Post: 01-08-2010, 07:19 AM
  5. add a table
    By anvi123 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 11-19-2009, 10:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •