+ 1

It isn't giving the required output, please help scrutinise.

https://code.sololearn.com/cgCK82ragNUp/?ref=app

11th Aug 2017, 1:14 AM
Dosunmu Ayanda Yusuf
Dosunmu Ayanda Yusuf - avatar
5 Réponses
+ 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
11th Aug 2017, 2:05 AM
Rrestoring faith
Rrestoring faith - avatar
+ 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.
11th Aug 2017, 1:17 AM
Rrestoring faith
Rrestoring faith - avatar
0
What is giving me is "int cannot be deferenced"
11th Aug 2017, 1:51 AM
Dosunmu Ayanda Yusuf
Dosunmu Ayanda Yusuf - avatar
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"); } } }
11th Aug 2017, 2:01 AM
Dosunmu Ayanda Yusuf
Dosunmu Ayanda Yusuf - avatar
0
This is my required output. Please enter to login! Name= ABC Password =1234 Login success.
11th Aug 2017, 3:21 AM
Dosunmu Ayanda Yusuf
Dosunmu Ayanda Yusuf - avatar