Computer Applications
Write a program in Java to input employee code, annual salary and deductible annual savings. Find the taxable income and calculate the income tax as per the following:
Taxable income = Annual salary - Deductible annual savings
Taxable Income (₹) | Income Tax |
---|---|
up to 200000 | 0% |
200001 to 500000 | 10% |
500001 to 1000000 | 20% |
above 1000000 | 30% |
Print the employee code, taxable income and income tax along with the appropriate messages.
Java
Java Conditional Stmts
22 Likes
Answer
import java.util.Scanner;
public class KboatAnnualSalary
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter Employee Code: ");
String empCode = in.nextLine();
System.out.print("Enter Annual Salary: ");
double s = in.nextDouble();
System.out.print("Enter Deductible Annual Savings: ");
double d = in.nextDouble();
double ti = s - d;
int r = 0;
if (ti <= 200000)
r = 0;
else if (ti <= 500000)
r = 10;
else if (ti <= 1000000)
r = 20;
else
r = 30;
double tax = ti * r / 100;
System.out.println("Employee Code: " + empCode);
System.out.println("Taxable Income: " + ti);
System.out.println("Income Tax: " + tax);
}
}
Output

Answered By
8 Likes
Related Questions
A student executes the following program segment and gets an error. Identify the statement which has an error, correct the same to get the output as WIN.
boolean x = true; switch(x) { case 1: System.out.println("WIN"); break; case 2: System.out.println("LOOSE"); }
Write a program to input three numbers (positive or negative). If they are unequal then display the greatest number otherwise, display they are equal. The program also displays whether the numbers entered by the user are 'All positive', 'All negative' or 'Mixed numbers'.
Sample Input: 56, -15, 12
Sample Output:
The greatest number is 56
Entered numbers are mixed numbers.Differentiate between if else if and switch-case statements
The statement that brings the control back to the calling method is:
- break
- System.exit(0)
- continue
- return