class income
{
public static void calc( )
{
Scanner sc= new Scanner(System.in);
System.out.println("Enter employee code");
String code= sc.next();
System.out.println("Confirm employee code");
String code2= sc.next();
System.out.println("employee code: " + code);
System.out.println("employee code: " + code2);
if (code2==code)
{
System.out.println("Enter salary");
int sal=sc.nextInt();
double hra = 0.2 * sal;
double da= 0.55 * sal;
double grosssal= sal + da + hra;
double pf = 0.06* grosssal;
double netsal= grosssal-pf;
System.out.println("net salary(gross salary - pf) ="+ netsal);
double taxd;
if (grosssal*12<=100000)
{ taxd = 0;
}
else if (grosssal*12<=500000)
{
taxd= 1000 + 0.1*((grosssal*12)-100000);
}
else
{
taxd= 5000 + 0.2*((grosssal*12)-500000);
}
double monthsal = netsal- (taxd/12);
System.out.println("employee code: " + code);
System.out.println("montly salary(gross salary - pf - tax)="+ monthsal);
System.out.println("tax deduction(annual)="+ taxd);}
else if(code!=code2)
{System.out.println("Invalid input");}
}
}
in the above code the output is always invalid input (which means that the computer thinks that the variables are unequal0 this even happens in cases where both the values are same variables code and code2 have the same value yet they are unequal
Aucun commentaire:
Enregistrer un commentaire