0
Whatâs wrong with this code, I'm trying to print a Pinery numbers based on the user's input.
import java.util.Scanner; // Import the Scanner class class Main { public static void main(String[] args) { Scanner myObj = new Scanner(System.in); // Create a Scanner object System.out.println("your input"); int a == 010011; if(myObj == a){ System.out.println("a"); } } } https://code.sololearn.com/cCLrh4gM1vQR/?ref=app
5 Answers
0
For starters you need to actually read the input. I assume it is going to be a whole number:
int input = myObj.nextInt();
When assigning a value to a variable, you use single equality symbols. You use double (==) only for comparison.
+ 4
Ahmed Hamde Ahmed Fetoh
please give more details about what u want from this code to help you By Commenting at the top of your code
+ 3
Scanner object methods are used to take user input.. You are not having any input. And comparing object with variable.. In myObj==a
And
int a == 01001; is invalid.
For integer input, use like
int a = myObj.nextInt() ; // integer input
For Comparing :
if(a == 10011) {..
+ 1
How about the other way around: What do you think the code does? And what are you trying to do?
0
I'm trying to print a Pinery numbers based on the user's input.