Java Question Set I – Conditional Statements in Java

4. Develop the program, which accepts the gross pay and produces the amount of tax owed. Where,

 

  • for a gross pay of $240 or less, the tax is 0%
  • for over $. 240 and $. 480 or less, the tax rate is 15%
  • for any pay over $480, the tax rate is 28%

This question is very similar to the previous question so the same logic and alternate logic can be applied to this question also.

import java.util.*;
class tax
{
	public static void main(String [] arg)
	{
		Scanner sc = new Scanner(System.in);
		double gross,tax;
		
		System.out.println("Enter the amount");
		gross=sc.nextDouble();
		
		if(gross<=240)
			tax=(gross/100)*0.0;
		else if(241>=480)
			tax=(gross/100)*15.0;
		else
			tax=(gross/100)*28.0;
			
		System.out.println("Tax Owed is = "+tax);
	}
}

Output:tax-calculator-java

Continue to next page for another question.

0 Responses on Java Question Set I - Conditional Statements in Java|

Leave a Message

Your email address will not be published. Required fields are marked *

CommentLuv badge

Pin It on Pinterest