+ 1
I am getting error in line 3 , 4 & 5 in Halloween Candy ....Here is my code
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); int houses = input.nextInt(); double chances = ((double )2)/houses*100; double a = Math.round(chances); System.out.print((int)a); } }
5 odpowiedzi
+ 6
You should use ceil() function instead of round() since we have to round up the nearest integer.
+ 4
😏 A.D singh.. 😎
No error in Code. Are you talking about test case?
+ 4
😏 A.D singh.. 😎
First do Math.ceil then Math.round like
System.out.print(Math.round(Math.ceil(chances)));
+ 1
Thank you ....
0
Yes..