but my code is not working. I have put double tax = 5/100*salary
but it's only showing 0.0
.
This is what I have tried.
package company;
import java.util.Scanner;
public class p6 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
System.out.print("Enter your Salary(in lakhs): ");
double salary=sc.nextDouble();
if(salary<2.5)
{
System.out.println("You don't have to pay any tax.");
}
else if(salary>=2.5&&salary<5.0)
{
System.out.println("You have to pay 5% of your salary as tax.");
double tax=5/100*salary;
System.out.println(tax);
}
else if(salary >=5.0 && salary < 10.0)
{
System.out.println("You have to pay 20% of your salary as tax.");
double tax=20/100*salary;
System.out.println(tax);
}
else {
System.out.println("You have to pay 30% of your salary as tax.");
double tax=30/100*salary;
System.out.println(tax);
}
}
}
OUTPUT:- Enter your Salary(in lakhs): 3 You have to pay 5% of your salary as tax. 0.0