I complete this script, but it seem a bit messy at the If else if statement. Can someone make it look nicer, or point out any other place I need to fix to make this better. Thank you

import java.io.*;
public class Assignment4
{
	public static void main(String[]args) throws IOException
	{
		//delcare and construct variables
		int marStatus, status, gross, earn, excess;
		BufferedReader dataIn= new BufferedReader(new InputStreamReader(System.in));

		//print prompts and get input
		System.out.print("Enter your relationship status (1)Single, or (2)Married ");
		marStatus = Integer.parseInt(dataIn.readLine());
		status = marStatus;
		try
		{
			marStatus = Integer.parseInt(dataIn.readLine());
			if (status

		System.out.print("Enter your weekly gross pay ");
		gross = Integer.parseInt(dataIn.readLine());
		earn = gross;

		     	// for single
		     	if (status==1)
		     	{
		     	if (earn <= 116)
		     		{
		            	System.out.println("The amount to withhold is 0");
		        	}
		        else if (earn>=116 && earn<=200)
		        	{
						excess = (earn-116);
						System.out.println("Excess earnings over wage bracket : $" + (excess));
						System.out.println("Tax withholding :$" + (excess * .10));
		        	}
		        else if (earn>=200 && earn<=693)
					{
						excess = (earn-200);
						System.out.println("Excess earnings over wage bracket : $" + (excess));
						System.out.println("Tax withholding :$" + (8.40+(excess*.15)));
		        	}
		        else if (earn>=639 && earn<=1302)
		        	{
						excess = (earn-639);
						System.out.println("Excess earnings over wage bracket : $" + (excess));
						System.out.println("Tax withholding :$" + (82.35+(excess*.25)));
		        	}
		        else if (earn>=1302)
					{
						excess = (earn-1302);
						System.out.println("Excess earnings over wage bracket : $" + (excess));
						System.out.println("Tax withholding :$" + (234.50+(excess*.27)));
		        	}
				}


				// for married
		     	if (status==2)
		     	{
		     	if (earn <= 264)
		     		{
		            	System.out.println("The amount to withhold is 0");
		        	}
		        else if (earn>=264 && earn<=471)
		        	{
						excess = (earn-264);
						System.out.println("Excess earnings over wage bracket : $" + (excess));
						System.out.println("Tax withholding :$" + (excess * .10));
		        	}
		        else if (earn>=471 && earn<=1457)
					{
						excess = (earn-471);
						System.out.println("Excess earnings over wage bracket : $" + (excess));
						System.out.println("Tax withholding :$" + (20.70+(excess*.15)));
		        	}
		        else if (earn>=1457 && earn<=1809)
		        	{
						excess = (earn-1457);
						System.out.println("Excess earnings over wage bracket : $" + (excess));
						System.out.println("Tax withholding :$" + (168.60+(excess*.25)));
		        	}
		        else if (earn>=1809)
					{
						excess = (earn-1809);
						System.out.println("Excess earnings over wage bracket : $" + (excess));
						System.out.println("Tax withholding :$" + (256.60+(excess*.27)));
		        	}
				}

	}
}

Use functions - will make code readable, maintainable. Draw common and put it at a single place. For example the SOPs could be handled in a function of their own dedicated to display/output instead of writing them so many times. Only the required values need to be accessible to them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.