Output

Variable Name     Value in Memory
status
income
tax
METERS_PER_INCH
weightInKilograms
heightInMeters
bmi
  1  import java.util.Scanner; 
  2  
  3  public class ComputeTax {
  4    public static void main(String[] args) {
  5      // Create a Scanner
  6      Scanner input = new Scanner(System.in);
  7  
  8      // Prompt the user to enter filing status
  9      System.out.println("(0-single filer, 1-married jointly or " +
 10        "qualifying widow(er), 2-married separately, 3-head of " +
 11        "household)");
 12      System.out.print("Enter the filing status: ");
 13      int status = input.nextInt();
 14  
 15      // Prompt the user to enter taxable income
 16      System.out.print("Enter the taxable income: ");
 17      double income = input.nextDouble();
 18  
 19      // Compute tax
 20      double tax = 0;
 21  
 22      if (status == 0) { // Compute tax for single filers
 23        if (income <= 8350)
 24          tax = income * 0.10;
 25        else if (income <= 33950)
 26          tax = 8350 * 0.10 + (income - 8350) * 0.15;
 27        else if (income <= 82250)
 28          tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
 29            (income - 33950) * 0.25;
 30        else if (income <= 171550)
 31          tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
 32            (82250 - 33950) * 0.25 + (income - 82250) * 0.28;
 33        else if (income <= 372950)
 34          tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
 35            (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 +
 36            (income - 171550) * 0.33;
 37        else
 38          tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
 39            (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 +
 40            (372950 - 171550) * 0.33 + (income - 372950) * 0.35;
 41      }
 42      else if (status == 1) { // Compute tax for married file jointly
 43        // Left as exercise
 44      }
 45      else if (status == 2) { // Compute tax for married separately
 46        // Left as exercise
 47      }
 48      else if (status == 3) { // Compute tax for head of household
 49        // Left as exercise
 50      }
 51      else {
 52        System.out.println("Error: invalid status");
 53        System.exit(1);
 54      }
 55  
 56      // Display the result
 57      System.out.println("Tax is " + (int)(tax * 100) / 100.0);
 58    }
 59  }