Wrong answwer cbecbdj

what is wrong with the code https://ide.codingblocks.com/s/228401
giving exact answer for est cases

Hey @mayank10 I have commented the mistake -
https://ide.codingblocks.com/s/228655
You were using round function to calculate the precision upto two places which do not work correctly.
see this -


see how it gives rounded off answer which is wrong.

which function should i use for round off

see the link to the code its there @mayank10
System.out.printf("%.2f\n",ans); //this one for upto 2 places

In this question u have to display the ans upto two decimal places not round off upto two decimal places.
example - 1.209 should be 1.20 not 1.21