0

What's wrong with my code

import java.util.Scanner; public class Comparison { public static void main(String[] args) { int number1; int number2; Scanner input = new Scanner(System.in); System.out.print("Enter first integer: "); // prompt number1 = input.nextInt(); // read first number from user System.out.print("Enter second integer: "); // prompt number2 = input.nextInt(); // read second number from user if (number1 == number2) System.out.printf("%d == %d%n", number1, number2); } }

14th Feb 2017, 6:15 AM
Hxhxn Djxx
Hxhxn Djxx - avatar
5 Answers
+ 3
It seems to work for me but only give output if the two entered numbers are equal.
14th Feb 2017, 6:18 AM
TamĂĄs Barta
TamĂĄs Barta - avatar
0
Yup works fine. What issue are you experiencing?
14th Feb 2017, 6:23 AM
ChaoticDawg
ChaoticDawg - avatar
0
I know that is what it is meant for
14th Feb 2017, 6:27 AM
Hxhxn Djxx
Hxhxn Djxx - avatar
0
it says a throw exception error
14th Feb 2017, 6:27 AM
Hxhxn Djxx
Hxhxn Djxx - avatar
0
If your getting it in the playground, be sure you are entering all your inputs, each on a separate line, when the input modal comes up. Otherwise, it won't work correctly.
14th Feb 2017, 6:31 AM
ChaoticDawg
ChaoticDawg - avatar