+ 1

Skee-ball challenge Java error [SOLVED]

import java.util.Scanner; import java.lang.*; public class Program { public static void main(String[] args) { Scanner xa = new Scanner(System.in); int a = xa.nextInt(); Scanner yb = new Scanner(System.in); int b = yb.nextInt(); if (a / 12 >= b) { System.out.println("Buy it!"); } else { System.out.println("Try again"); } } } I copied this method in other programming languages but I seem to get an error here in Java. Can someone help?

2nd May 2020, 5:43 AM
Ārtēmī§
Ārtēmī§ - avatar
2 Respuestas
+ 4
Don't declare two scanners. Use the same one. Scanner x = new Scanner(System.in); int a = x.nextInt(); int b = x.nextInt();
2nd May 2020, 7:55 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
Ok Hatsy Rei, Thanks
2nd May 2020, 8:25 AM
Ārtēmī§
Ārtēmī§ - avatar