0
Halloween candy round/ceil
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner input = new Scanner(System.in); int houses = input.nextInt(); int bill=2; double proba; //your code goes here do { if (houses<3) System.out.println ("error"); } while (houses<3); { proba=(double) bill / (double) houses; proba*=100; proba=Math.ceil(proba); System.out.println ((int)proba); } } } Hello everyone I have a question about this problem. With this code I passed the test but I don't understand why I have to use Math.ceil and not Math.round (it fail with the 3 last inputs). Thanks
2 Respuestas
+ 2
Ok so the probleme was my level of english ^^. I thought rounded up to the nearest meant nearest up or down.
Problem solved I need to be more careful when I'm reading something not in my mother tongue.
Thank you !