+ 3

Help with the error in my JAVA code pls....

I have made a JAVA program on an ATM but the output is coming out as Invalid every time even when I enter the correct id and password.....Since this is a school project, they have instructed me not to use arrays.....due to which I am getting this difficulty.... Here's the code for the program..... https://code.sololearn.com/ct6qQ9ZtnHxl/#java Please help me in solving this error as soon as possible... Thanks in advance!

8th Oct 2017, 10:19 AM
Karan Kumar
Karan Kumar - avatar
16 Antworten
+ 6
Yours inputs are defined as numbers (double and int). In this case, your line 29 is wrong: if(id==003457001&&pw==1290) correct is: if(id==3457001&&pw==1290) Maybe is better to define inputs as String, but that depends on your choices and decisions. Nice code...keep coding :)
8th Oct 2017, 10:52 AM
LukArToDo
LukArToDo - avatar
+ 4
After you update inputs as Strings use instead id=="003457001" id.equals("003457001") It is same and with pw.
8th Oct 2017, 11:11 AM
LukArToDo
LukArToDo - avatar
+ 4
Also, I recommend that you use trim() in input line : String id=in.nextLine().trim()
8th Oct 2017, 11:13 AM
LukArToDo
LukArToDo - avatar
+ 4
Karan, please update all lines if( id=="... " &&pw=="...") with if (id.equals("...")&&pw.equals("... ")) if you want that your code works fine :)
8th Oct 2017, 11:42 AM
LukArToDo
LukArToDo - avatar
+ 4
Very nice code Karan. But for Sololearn playground inputs (more than one line) is always confusing. So, maybe will be good to put additional explanation (you already put some of) as: Please input as: id number (enter/next line) password (enter/next line) number of options (1,2 or 3) (enter/next line) amount (submit) What you think?
8th Oct 2017, 11:57 AM
LukArToDo
LukArToDo - avatar
+ 3
@LukArToDo I just updated the code but still showing the same error.....chaech out the link in the description pls
8th Oct 2017, 11:01 AM
Karan Kumar
Karan Kumar - avatar
+ 3
I do not know what to think 🤔 Nice app, but there are many ways to communicate, for those who want it.
11th Oct 2017, 7:00 PM
LukArToDo
LukArToDo - avatar
+ 2
Then the account number has to be shortened isn't it
8th Oct 2017, 10:51 AM
Karan Kumar
Karan Kumar - avatar
+ 2
Oh okay thanks bro ;)
8th Oct 2017, 10:53 AM
Karan Kumar
Karan Kumar - avatar
+ 2
Thanks a lot bro....Seems like Sololearn saves me every time XD And I just updated the code to a final one... So just check it out!!
8th Oct 2017, 11:35 AM
Karan Kumar
Karan Kumar - avatar
+ 2
Oh Sorry That code was an old one Check this one https://code.sololearn.com/cl3RW6UVe77F/#java
8th Oct 2017, 11:43 AM
Karan Kumar
Karan Kumar - avatar
+ 2
Oh Alright.....No problem! I'll just copy-paste it now! ;D
8th Oct 2017, 12:02 PM
Karan Kumar
Karan Kumar - avatar
11th Oct 2017, 6:36 PM
Karan Kumar
Karan Kumar - avatar
+ 1
It works! Just need to separate inputs with an ENTER
8th Oct 2017, 10:43 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
Oh wait, even if the account number entered and passowrd is correct, it does not work
8th Oct 2017, 10:44 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
Replace nextDouble with nextInt
8th Oct 2017, 10:48 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar