+ 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 } }

20th Feb 2020, 4:45 AM
Baktybek Tazhibaev
Baktybek Tazhibaev - avatar
6 Respostas
+ 4
Do Math.round after Math.ceil like Math.round(Math.ceil(r));
20th Feb 2020, 5:01 AM
A͢J
A͢J - avatar
+ 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
20th Feb 2020, 5:04 AM
Tanmay Gupta
Tanmay Gupta - avatar
+ 1
What's wrong with it?
20th Feb 2020, 4:46 AM
Baktybek Tazhibaev
Baktybek Tazhibaev - avatar
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)
20th Feb 2020, 7:45 AM
Jayakrishna 🇮🇳
0
You can simply cast to int when doing Math.ceil
24th Feb 2020, 8:14 AM
Mohammadyar Barandov
Mohammadyar Barandov - avatar