Question
Given below is a hypothetical table showing rates of Income Tax for male citizens below the age of 65 years:
Taxable Income (TI) Income Tax
< 1,60,000 Nil
>1,60,000 and <= 5,00,000 ( TI – 1,60,000 ) * 10%
> 5,00,000 and <= 8,00,000 [(TI – 5,00,000 ) *20%] + 34,000
> 8,00,000 [(TI – 8,00,000 ) *30% ] + 94,000
Write a program to input the age, gender (male or female) and Taxable Income of a person.If the age is more than 65 years or the gender is female, display “wrong category”. If the age is less than or equal to 65 years and the gender is male, compute and display the Income Tax payable as per the table given above.
Share code with your friends
Share on whatsapp
Share on facebook
Share on twitter
Share on telegram
Code
import java.util.Scanner;
public class program5
{
public static void main(String[] args)
{
int age=0;
double tax=0,income=0;
String gender="";
Scanner sc = new Scanner(System.in);
System.out.print("Enter age: ");
age = sc.nextInt();
System.out.print("Enter gender: ");
gender = sc.next();
System.out.print("Enter taxable income: ");
income = sc.nextDouble();
if (age > 65 || gender.equals("female"))
{
System.out.println("Wrong category");
}
else
{
if (income <= 160000)
{
tax = 0;
}
else if(income > 160000 && income <= 500000)
{
tax = (income - 160000) * 10 / 100;
}
else if(income > 500000 && income <= 800000)
{
tax = (income - 500000) * 20 / 100 + 34000;
}
else
{
tax = (income - 800000) * 30 / 100 + 94000;
}
System.out.println("Income tax is " + tax);
}
}
}