0
How do I unhide test cases?
I'm trying to do the Halloween Candy challenge. 2 passed but 3 test cases failed but I can't see the cases. Is there a way to unhide them?
7 Respostas
+ 8
Brian i think the problem is in the format of your output .Math.ceil returns a double value.
So you have to change double value to integer you can do it by placing (int) before the value or you can also use formatter just like this
import java.util.Scanner;
import java.text.*;
class Program
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double houses = input.nextDouble();
if(houses < 2) {
System.out.println("You didn't visit enough houses");
}
else {
double chance = (2/houses)*100;
DecimalFormat df=new DecimalFormat("#");
System.out.println(df.format(Math.ceil(chance)));
}
}
}
+ 7
If you can see the inputs and expected outputs, you could hard code the answers and never solve the problem. If you post your code here, those of us that have solved it can help you fix it.
+ 7
Just try and try until your problem become solved.
And don't hesitate to ask question in Q&A it don't make anyone smaller.
Community are always there to help everyone.
+ 4
No.
+ 2
The only thing that has come close to solving was using Math.round() but when I searched everyone has been saying to use ceil().
https://code.sololearn.com/c7rvh3cqanh6/?ref=app
+ 1
0_0 Mägár Sám Äkà Nüllpøïntêr Èxëcéptïön Thanks, placing (int) did the trick!
+ 1
The whole idea behind hidden cases is to prevent people from hard coding all answers.