0

Can anyone help me with this code? Please tell me what's wrong with it.

import java.util.Scanner; public class Program { public static void print (int x, int y) { if (x=y) { System.out.println("1"); } else if (x>y) { System.out.println("2"); } else { System.out.println("3"); } } public static void main (String [] args) { Scanner in1 = new Scanner (System.in); int x,y; System.out.println ("Enter an integer for x"); x = in1.nextInt(); System.out.println ("Enter an integer for y"); y = in1.nextInt(); print (x,y); } }

23rd Oct 2020, 10:07 AM
Kalvin Villaruel
Kalvin Villaruel - avatar
2 Answers
+ 4
if( x == y). Don't forget to enter each value on separate lines like: 1 1 and press submit.
23rd Oct 2020, 10:11 AM
QTWizard
0
I see so I forgot about that double equal sign. Thank you for your help 😊
23rd Oct 2020, 10:29 AM
Kalvin Villaruel
Kalvin Villaruel - avatar