calculate income tax || conditional statements || java program || Java

In this, we are going to write a simple program for Income Tax Calculation for Different Age Groups in Java.



import java.util.*;

class Tax
{
    public static void main(String[] args) 
    {
        Scanner sc = new Scanner(System.in);
        int age;
        String gender;
        float ti, it;
        System.out.println("Enter the age:");
        age = sc.nextInt();
        System.out.println("Enter the gender:");
        gender = sc.nextLine();
        sc.nextLine();
        System.out.println("Enter the taxable income:");
        ti = sc.nextFloat();
        if (age > 65 && gender.equals("female"))
        {
            System.out.println("Wrong category");
        }
        else 
        {
            if (ti <= 160000)
            {
                it = 0;
            }
            else if (ti > 160000 && ti <= 500000)
            {
                it = 10 / 100f * (ti - 160000);
            }
            else if (ti > 500000 && ti <= 800000)
            {
                it = 20 / 100f * (ti - 500000) + 34000;
            }
            else
            {
                it = 30 / 100f * (ti - 800000) + 94000;
            }
            System.out.println("Income Taxable:" + it);
        }
    }
}

#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post