+ 1
Halloween candy
import java.util.Scanner; import java.lang.*; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); int houses = input.nextInt(); double x = (2/houses); double r = x*100; System.out.println(Math.ceil(r)); //your code goes here } }
6 Respuestas
+ 4
Do Math.round after Math.ceil
like Math.round(Math.ceil(r));
+ 4
You need to round of to the nearest integer.
Use the Math.round function in the last to get the value and then print it
+ 1
What's wrong with it?
0
Since houses in int value and 2 is also int, then it always int value.
Result always 0 when houses >2,
So, check ones, In any case, round, or ceil or without any, r value don't get modified, in your program...
Use x= 2.0 /house.
And also convert final result to int in outputting..
By (int) Math.ceil(r)
0
You can simply cast to int when doing Math.ceil