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

6th Aug 2022, 11:38 AM
Ahmed Hamde Ahmed Fetoh
Ahmed Hamde Ahmed Fetoh - avatar
5 Respostas
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.
6th Aug 2022, 1:07 PM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 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
6th Aug 2022, 11:55 AM
Aly Alsayed
Aly Alsayed - avatar
+ 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) {..
6th Aug 2022, 12:41 PM
Jayakrishna 🇼🇳
+ 1
How about the other way around: What do you think the code does? And what are you trying to do?
6th Aug 2022, 11:49 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
0
I'm trying to print a Pinery numbers based on the user's input.
6th Aug 2022, 12:25 PM
Ahmed Hamde Ahmed Fetoh
Ahmed Hamde Ahmed Fetoh - avatar