+ 1
It isn't giving the required output, please help scrutinise.
5 odpowiedzi
+ 3
Change:
int password = input.nextInt(1234);
To:
int password = input.nextInt();
Change:
password.equals("1234")
To:
password == 1234
Or
Integer.toString(password).equals("1234")
// But at this point you'd might as well just use a string instead of int
+ 2
Works for me.
You used next() so you'd have to input everything like this:
ABC 1234
Then it works.
If this isn't what you wanted, use nextLine() instead.
0
What is giving me is "int cannot be deferenced"
0
New code, giving "int cannot be deferenced"
import java.util.Scanner;
public class Input
{
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.print("please enter to login! \nName =");
String login=input.next("ABC");
System.out.print("\npassword=");
int password= input.nextInt(1234);
if(login.equals("ABC")&& password.equals("1234")){
System.out.println("Login success!");
}
else{
System.out.println("Login fail");
}
}
}
0
This is my required output.
Please enter to login!
Name= ABC
Password =1234
Login success.