473,324 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Making a table with tax information

Hello, I need help making a table based off my tax code I made, the tax code was a little, but I need help with the table part also. The table should look like this:
Expand|Select|Wrap|Line Numbers
  1. Income | Single Married | Joint Married | Separate | Head of house
  2. 50000   |  9846         |  7296         |  10398    | 8506
  3. 50050   |  9859         |  7309         |  10411    | 8519
  4. ........
  5. 59950   |  12532         |  9982         |  13190   |  11192
  6. 60000   |  12546         |  9996         |  13205   |  11206
Here is my code:


Expand|Select|Wrap|Line Numbers
  1. //Input: put in the income for the single, married, or head of the household taxes
  2. //Process: Using a method to computeing and determining the taxes by less then eual to and by substracting
  3. //Output: Display the results
  4. //Purpose: The program computes the tax for the taxable income based on the filing status
  5.  
  6. import javax.swing.JOptionPane;
  7.  
  8. public class ComputeTaxWithMethod {
  9. public static void main (String [] args) {
  10. // Prompt the user to enter filing status
  11. String letters = JOptionPane.showInputDialog(
  12. "Enter the filing status:");
  13. int status = Integer.parseInt(letters);
  14.  
  15. // Prompt the user to enter taxable income
  16. String symbol = JOptionPane.showInputDialog(
  17. "Enter the taxable income:");
  18. double income = Double.parseDouble(symbol);
  19.  
  20. //Display the result
  21. JOptionPane.showMessageDialog(null, "Tax is " +
  22. (int)(computeTax(status, income) * 100) / 100.0);
  23.  
  24. System.out.println("income \t\t tax ");
  25. System.out.println("________________________");
  26. System.out.println(income + "\t\t" + (int)(computeTax(status, income) * 100) / 100.0);
  27.  
  28.  
  29. }
  30.  
  31.  
  32. public static double computeTax(double income,
  33. int r1, int r2, int r3, int r4, int r5) {
  34. double tax = 0;
  35.  
  36. if (income <= r1)
  37. tax = income * 0.10;
  38. else if (income <= r2)
  39. tax = r1 * 0.10 + (income - r1) * 0.15;
  40. else if (income <= r3)
  41. tax = r1 * 0.10 + (r2 - r1) * 0.15 + (income - r2) * 0.27;
  42. else if (income <= r4)
  43. tax = r1 * 0.10 + (r2 - r1) * 0.15 + (r3 - r2) * 0.27 + (income - r4) * 0.35;
  44. else
  45. tax = r1 * 0.10 + (r2 - r1) * 0.15 + (r3 - r2) * 0.27 + (r4 - r3) * 0.30 + (r5 - r4) * 0.35 + (income - r5) * 0.386;
  46.  
  47. return tax;
  48. }
  49.  
  50. public static double computeTax(int status, double income) {
  51. switch (status) {
  52. case 0: return //Compute tax for Single
  53. computeTax(income, 6000, 27950, 67700, 141250, 307050);
  54. case 1: return //Compute tax for married joint
  55. computeTax(income, 12000, 46700, 112850, 171950, 307050);
  56. case 2: return //Compute tax for married separately
  57. computeTax(income, 6000, 23350, 56425, 85975, 153525);
  58. case 3: return //Compute tax for head of a house
  59. computeTax(income, 10000, 37450, 96700, 156600, 307050);
  60. default: return 0;
  61. }
  62. }
  63. }
  64.  
Oct 21 '07 #1
2 3377
Nevermind I solved it
Oct 22 '07 #2
Expand|Select|Wrap|Line Numbers
  1. public class test {
  2.  
  3.     public static void main(String[] args) {
  4.         // Display the number title
  5.  
  6.                 System.out.println("Taxable      Single    Married/    Married/    Head of");
  7.                 System.out.print("Income        Filer     Joint      Separate     House");
  8.  
  9.  
  10.                 System.out.println("\n----------------------------------------------------------");
  11.  
  12.                 // Display table body
  13.                 double taxableIncome = 50000;
  14.                 while (taxableIncome <= 60000){
  15.                     System.out.printf("%3.0f" + " | ", taxableIncome);
  16.  
  17.                     for (int status = 0; status < 4; status++) {
  18.                         // Display the product and align properly
  19.                         System.out.printf("%11.0f", computetax(status, taxableIncome));
  20.                     }
  21.                     System.out.println("");
  22.                     taxableIncome = taxableIncome + 50;
  23.                 }
  24.             }
  25.  
  26.  
  27.         public static double computetax(int status, double taxableIncome) {
  28.  
  29.             double tax = 0;
  30.  
  31.             if (status == 0) {
  32.                 if (taxableIncome <= 8350)
  33.                     tax = taxableIncome * 0.10;
  34.                  else if (taxableIncome <= 33950)
  35.                         tax = 8350 * 0.10 + (taxableIncome - 8350) * 0.15;
  36.                       else if (taxableIncome <= 82250)
  37.                         tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
  38.                           (taxableIncome - 33950) * 0.25;             
  39.             }
  40.             else if (status == 1) {
  41.                 if (taxableIncome <= 16700)
  42.                     tax = taxableIncome * 0.10;
  43.                     else if (taxableIncome <= 67900)
  44.                         tax = 16700 * 0.10 + (taxableIncome - 16700) * 0.15;
  45.             }
  46.             else if (status == 2) {
  47.                 if (taxableIncome <= 8350)
  48.                     tax = taxableIncome * 0.10;
  49.                  else if (taxableIncome <= 33950)
  50.                         tax = 8350 * 0.10 + (taxableIncome - 8350) * 0.15;
  51.                       else if (taxableIncome <= 68525)
  52.                         tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
  53.                           (taxableIncome - 33950) * 0.25;
  54.             }
  55.             else if (status == 3) {
  56.                 if (taxableIncome <= 11950)
  57.                     tax = taxableIncome * 0.10;
  58.                 else if (taxableIncome <= 45500)
  59.                     tax = 11950 * 0.10 + (taxableIncome - 11950) * 0.15;
  60.                 else if (taxableIncome <= 117450)
  61.                     tax = 11950 * 0.10 + (45500 - 11950) * 0.15 +
  62.                     (taxableIncome - 45500) * 0.25;
  63.             }
  64.             return tax;
  65.         }
  66.  
  67.  
  68. }
Nov 1 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Waqas | last post by:
Please see the detail of tables with fields in SQL server 2000. ·Table Student .Table Good Qualities ( It is a list of Students) (It is a list of Good Qualities)...
61
by: Toby Austin | last post by:
I'm trying to replace <table>s with <div>s as much as possible. However, I can't figure out how to do the following… <table> <tr> <td valign="top" width="100%">some data that will...
5
by: Sami | last post by:
Please bear with me, and if you answer this question, please do it step by step. I am new at Access, not at all sophisticated. I am using Office XP. This will need to be read in Access for...
3
by: Kenjamin.Lafayette | last post by:
Here is the scenario. I have a list of people, what building they work in, and on what days. Is there a way in access to pull up this database and have it make a list based only on the days,...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
1
by: keithb | last post by:
My ASP.NET 2.0 application has a User Control that contains a DataList that is unable to get style information from a style located in a css file in the themes folder. The user control CssClass and...
69
by: kabradley | last post by:
Alrighty Guys and Gals, I have another question that I hope you all can help me with. I have a report that uses a cross-tab query as its record source. This cross-tab query is getting all of its...
1
by: HACKhalo2 | last post by:
Hi. I'm helping a friend of mine develop an online game, which is currently outdated. The person making skins for the site came up with a cool looking NavBar (found at...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.