+ 1
Skee-Ball drives me crazy :D (Test case #3)
Hello Folks! I can't get past test case#3. I'm forever grateful for your help. I assume it's some sort of rounding error, but I don't know yet how to fix it. That's my code: import java.util.Scanner; public class SkeeBall { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); int score = input.nextInt(); input.close(); if(((score/12)>=40) && (score>12)){ //I might aswell leave the '&&(score>12) part away, makes no difference System.out.println("Buy it!"); }else { System.out.println("Try again"); } } }
11 Antworten
+ 2
Problem inputs tickets also. So You need to take Tickets are also as input..
+ 2
The challenge requires 2 inputs. Your points and then the price of the squirt gun.
+ 1
Oh! How silly of me. I'm sort of glad it's my reading comprehension and not the coding.
Thanks a lot! :)
+ 1
Bethany Faulkner Good luck and have fun!
+ 1
Can I see your code? Its hard to diagnose without looking at it.
+ 1
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int score = input.nextInt();
int cost = input.nextInt();
if(((score/12)>=cost) && (score>12)){
System.out.println("Buy it!");
} else {
System.out.println("Try again");
}
}
}
+ 1
There is no need of score>12. Is it?
Rest all fine..
+ 1
Bethany Faulkner No need for "&& (score > 12)"
It makes the else statement execute since you require the score variable to be less than 12.
+ 1
I've still got no idea why I can't pass #3.
0
I changed (score/12)>=40 to (score/12)>=cost (and added int cost = input.nextInt() before) and it's still #3, which makes me believe that must be some calculation error. I've got no idea.
0
Bethany Faulkner Can you link your code please? It helps when diagnosing it.