What is the problem with my code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the problem with my code?

I've wrote this program, but I got every time when I run it 0.0 but I don't know how. Here is the program: 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 = 0.0; //your code goes here double no1 = 2 / houses; double no2 = no1 *100; chances = no2; System.out.println(Math.ceil(chances)); } }

13th Jul 2020, 6:28 AM
Kovács Levente
1 Answer
+ 2
Kovács Levente do Math.round after Math.ceil and check condition for houses which should be greater than or equals to 3.
13th Jul 2020, 6:32 AM
A͢J
A͢J - avatar