0

Getting all sorts of "illegal start of expression" and "; expected" and "class expected" errors mostly pertaining to my extra methods (besides the main).

Any takers?

import java.util.Scanner;

/**

    This program will calculate income tax based on a person's income.

*/


public class Income

{

    public static void main(String[]args)

    {

    double income, tax;
    int filingStatus;
    String marriage;

    Scanner kb = new Scanner(System.in);

    //Display title
    System.out.println("                   **INCOME TAX CALCULATOR**");


    //Call interactive income tax input with >50,000 check.
    income=readIncome();

    //Call the menu display method
    filingStatus=displayMenu();

    //Call the marriage string method.
    marriage=marriageStatus(filingStatus);

    //Call the compute income tax method
    tax=computeTax(income, filingStatus);

    //Call the display information method
    display(income, filingStatus, tax);


    //The Income method.
    public static double readIncome()
    {

    double taxIncome;

    System.out.print("Please enter your taxable income (must be more than $50,000): ");
    taxIncome = kb.nextDouble();
    while (taxIncome <50000)
        System.out.println("Please enter an amount larger than $50,000");
    return taxIncome;  //returns taxIncome value to the income value in main method

    }


    //The displayMenu method.
    public static int displayMenu()
    {


    int status;

    System.out.println("           **************************************");
    System.out.println("           *         Filing Status Menu         *");
    System.out.println("           *                                    *");
    System.out.println("           *   1 - Single                       *");
    System.out.println("           *   2 - Married Filing Jointly       *");
    System.out.println("           *   3 - Married Filing Separately    *");
    System.out.println("           *   4 - Head of Household            *");
    System.out.println("           *                                    *");
    System.out.println("           *                                    *");
    System.out.println("           **************************************");
    System.out.print("\n\nPLEASE ENTER YOUR FILING STATUS USING THE APPROPRIATE NUMBER IN THE ABOVE MENU: ");
    status = kb.nextInt();
    while (int < 1 || int > 4)       
        {
        System.out.println("You must enter either 1, 2, 3 or 4 using the above menu. Try Again: ");
        status = kb.nextInt();
        }
    return status; //returns inputted status to the filingStatus variable in the main method.
    }


    //The marriage status method.
    public static String marriageStatus(int filingStatus)
    {
    String marriage2;

    if (filingStatus = 1)
        marriage2 = "Single";
    else if (filingStatus = 2)
        marriage2 = "Married Filing Jointly";
    else if (filingStatus = 3)
        marriage2 = "Married Filing Separately";
    else if (filingStatus = 4)
        marriage2 = "Head of Household"; 
    return marriage2;  //returns marriage2 string to marriage variable in main method.
    }   

    //The compute income tax method.
    public static double computeTax(double income, int filingStatus)
    {
    double incomeTax;

    if (filingStatus == 1)
        incomeTax = (11158.50 + .31 * (income - 49300));
    else if (filingStatus == 2)
        {
        if (income > 34000 && income < 82150)
            incomeTax = (5100 + .28 * (income - 34000));
        else if (income >= 82150)
            incomeTax = (18582 + .31 * (income - 82150));
        }
    else if (filingStatus == 3)
        incomeTax = (9291 + .31 * (income - 41075));
    else if (filingStatus == 4)
        {
        if (income > 27300 && income < 70450)
            incomeTax = (4095 + .28 * (income - 27300));
        else if (income >= 70450)
            incomeTax = (16177 + .31 * (income - 70450));
        }
    return incomeTax;  //returns incomeTax value to the tax variable in the main method
    }


    //The display information method.
    public static void display(double income, double tax, int filingStatus)
    {
    System.out.println("             RESULTS OF COMPUTATIONS");
    System.out.println("\n       Taxable Income:   $" + income);
    System.out.println("       Filing Status:     " + marriage);
    System.out.println("       Tax:              $" + tax);        
    }
    }
}

Edited by mike_2000_17: Fixed formatting

1
Contributor
1
Reply
4
Views
8 Years
Discussion Span
Last Post by EJD
0

Thanks to anyone who read through this, but I discovered my main problem of not closing my main method nor using the System.exit sequence.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.