+ 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"); } } }

4th Mar 2020, 8:03 AM
Bethany Faulkner
Bethany Faulkner - avatar
11 Antworten
+ 2
Problem inputs tickets also. So You need to take Tickets are also as input..
4th Mar 2020, 8:24 AM
Jayakrishna 🇼🇳
+ 2
The challenge requires 2 inputs. Your points and then the price of the squirt gun.
4th Mar 2020, 8:27 AM
かんでん
かんでん - avatar
+ 1
Oh! How silly of me. I'm sort of glad it's my reading comprehension and not the coding. Thanks a lot! :)
4th Mar 2020, 9:06 AM
Bethany Faulkner
Bethany Faulkner - avatar
+ 1
Bethany Faulkner Good luck and have fun!
4th Mar 2020, 9:08 AM
かんでん
かんでん - avatar
+ 1
Can I see your code? Its hard to diagnose without looking at it.
4th Mar 2020, 10:02 AM
かんでん
かんでん - avatar
+ 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"); } } }
4th Mar 2020, 10:25 AM
Bethany Faulkner
Bethany Faulkner - avatar
+ 1
There is no need of score>12. Is it? Rest all fine..
4th Mar 2020, 10:38 AM
Jayakrishna 🇼🇳
+ 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.
4th Mar 2020, 11:22 AM
かんでん
かんでん - avatar
+ 1
I've still got no idea why I can't pass #3.
6th Mar 2020, 11:48 AM
Bethany Faulkner
Bethany Faulkner - avatar
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.
4th Mar 2020, 9:59 AM
Bethany Faulkner
Bethany Faulkner - avatar
0
Bethany Faulkner Can you link your code please? It helps when diagnosing it.
6th Mar 2020, 11:49 AM
かんでん
かんでん - avatar