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.
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
Related Questions
Differentiate between if else if and switch-case statements
An air-conditioned bus charges fare from the passengers based on the distance travelled as per the tariff given below:
Distance Travelled Fare Up to 10 km Fixed charge ₹80 11 km to 20 km ₹6/km 21 km to 30 km ₹5/km 31 km and above ₹4/km Design a program to input distance travelled by the passenger. Calculate and display the fare to be paid.
Rewrite the following code using single if statement.
if(code=='g') System.out.println("GREEN"); else if(code=='G') System.out.println("GREEN");