 # Help with this code!? Stuck from 2 days

I have been trying to solve the Gross Salary(FLOW011) problem under beginner section. I have written a code which is working fine for the inputs given in the page but the codechef compiler is showing error, can someone please point out the error.

(UPDATED) Still it’s giving same error.
Here is the code.

``````   import java.util.Scanner;

class Flow011 {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
double n = in.nextDouble();
while(n-->0){
int  salary = in.nextInt();
double gross;
if(salary<1500){
gross = salary+(salary*0.1)+(salary*0.9);
}
else{
gross = salary + 500 + (salary*0.98);
}
if(gross==Math.floor(gross)){
System.out.println((int)gross);
}
else
System.out.printf("%g\n",gross);
}

in.close();
}
}``````

First, Please add new line character after printing every test case solution. And second %g is returning 2406.00 instead of 2406 so it is giving WA, you need format this in required format.

Here

``````Input
1
2110
4677.80
Expected Output
4677.8
``````

They way this program checks for correct answer, is by checking if what you print is exactly same as what is expected. Try to get rid of this extra 0 here and see. Your logic and syntax are, else, very correct.

Hi,

We are sorry. This problem had precision issues, and has been fixed now. Now any solutions which are within 10^(-2) of the correct answer will be accepted, irrespective of the number of digits printed.

Cheers,

CodeChef

Check your code for sample Input. For second number, it prints .16 in decimal instead of .2 . IDK why though…

nope I changed it, still error(updated code above).

Did you check my comment?

yeah I updated my code, now it’s rounding up to .2 instead of .16----.
Still the compiler would say error.

thankyou admin 