Friday, 10 June 2022

Given below is a hypothetical table showing rate of income tax from male citizens below the age of 65 year:

Taxable Income (TI) Income Tax

Up to Rs. 5,00,000 Nil
More than Rs. 5,00,000 and less than or equal to Rs. 10,00,000 (TI – 5,00,000) x 10%
More than R. 10,00,000 and less than or equal to Rs. 20,00,000 (TI – 10,00,000) x 20% + 30,000
More than Rs. 20,00,000 (TI – 20,00,000) x 30% + 90,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.




import java.util.*;
public class Assignment3_Tridib
{
    public static void main(String args[])
    {
        String gen="";
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter the age of a person: ");
        int age = sc.nextInt();
        System.out.print("Enter the gender: ");
        gen = sc.next();
        
        
        if(age < 65 && gen.equalsIgnoreCase("male"))
        {
            System.out.print("Enter the taxable income: ");
            int TI = sc.nextInt();
        
            if(TI <= 500000)
            {
                System.out.println("Nil");
            }
            else if(TI > 500000 && TI <= 1000000)
            {
                System.out.println("Income tax payable: " + (TI - 500000) * 0.1);
            }
            else if(TI > 1000000 && TI <= 2000000)
            {
                System.out.println("Income tax payable: " + ((TI - 1000000) * 0.2) + 30000);
            }
            else if(TI > 2000000)
            {
                System.out.println("Income tax payable: " + ((TI - 2000000) * 0.3) + 90000);
            }
        }
        else
            System.out.println("Wrong category");
    }
}





Output:




No comments:

Post a Comment