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:
Here is my code:
Code:
Income | Single Married | Joint Married | Separate | Head of house 50000 | 9846 | 7296 | 10398 | 8506 50050 | 9859 | 7309 | 10411 | 8519 ........ 59950 | 12532 | 9982 | 13190 | 11192 60000 | 12546 | 9996 | 13205 | 11206
Code:
//Input: put in the income for the single, married, or head of the household taxes
//Process: Using a method to computeing and determining the taxes by less then eual to and by substracting
//Output: Display the results
//Purpose: The program computes the tax for the taxable income based on the filing status
import javax.swing.JOptionPane;
public class ComputeTaxWithMethod {
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;
}
}
}
Comment