You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first step is to ask whether the user is single or married, then based on that information it takes their secondary input (income) and calculates how much tax they must pay.
*/
importjava.util.Scanner;
publicclassIncomeTax_Calculate{
publicstaticvoidmain(String[] args) {
Scannersc=newScanner(System.in);
System.out.println("Enter your income in lakhs par annum: ");
floattax=0;
floatincome=sc.nextFloat();
if (income<=2.5) {
tax = tax + 0;
}
elseif (income>5f && income<=10.0f) {
tax=tax+0.05f*(5.0f-2.5f);
tax=tax+0.2f*(income-5f);
}elseif (income>10.0f) {
tax=tax+0.05f*(5.0f-2.5f);
tax=tax+0.2f*(10.0f-5f);
tax=tax+0.3f*(income-10.0f);
}
System.out.println("The total tax paid by the employee is : "+tax);