Write a program that takes as input the marital status (“single” or “married”, c
ID: 3620823 • Letter: W
Question
Write a program that takes as input the marital status (“single” or “married”, case insensitive) and the taxable income (double), and computes taxes for the following schedule. The program should use a constant (declared with the modifier final) to represent each base tax (highlighted in yellow) and tax rate (highlighted in red). Also, use format specifiers to display taxes with exactly two digits after decimal point.Hi, I'm a beginner Java user and I am having trouble with DecimalFormat and with the if else statements. I am receiving compiling errors for both and I am a little unsure how to continue on at this point. Any help or advice or suggestions would be most appreciated!
Errors involve the formulas I have put in to tax and the if(status.equals("Single"));
Here is my program:
// This program calculates the user's income tax
import java.util.Scanner;
import java.text.DecimalFormat;
public class Tax
{
public static void main(String [] args)
{
// Create a scanner object to read from the keyboard
Scanner keyboard = new Scanner(System.in);
// Create a DecimalFormat object
DecimalFormat tax = new DecimalFormat("$0.00");
// Identifier declarations
double income;
int single, married;
// Marital Status: Single or Married
System.out.println("Enter your marital status (single or married): ");
int c = System.in.read();
switch ((char) c) {
case 's': case 'S':
System.out.println("Single");
break;
case 'm': case 'M':
System.out.println("Married");
break;
default:
System.out.println("illegal marital status");
break;
}
// Taxable Income
System.out.println("Enter your taxable income: ");
income = keyboard.nextDouble();
// Marital Status: Single
if(status.equals("Single"));
else if(income > 0 && income <= 8000)
tax = income*.10;
else if(income > 8000 && income <= 32000)
tax = (income - 8000)*.15 + 800;
else if(income > 32000)
tax = (income - 32000)*.25 + 4400;
else
System.out.println("-- illegal income --");
// Marital Status: Married
if(status.equals("Married"));
else if(income > 0 && income <= 16000)
tax = income*.10;
else if(income > 16000 && income <= 64000)
tax = (income - 16000)*.15 + 1600;
else if(income > 64000)
tax = (income - 64000)*.25 + 8800;
else
System.out.println("-- illegal income --");
// Display Results
System.out.println("Your income tax is" + tax.format(tax));
}
}