Click here to Skip to main content
16,022,828 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more: (untagged)
The loop cant be stop eventho the key-in matches. Can anyone fix this and tell me my mistake?
Greatly appreciate it if so!


<br />import java.io.*;<br /><br />public class A<br />{<br />public static void main(String args[]) throws IOException<br />{<br />BufferedReader stdin=new BufferedReader (new InputStreamReader(System.in));<br />//char n,p;<br />String name,pwd;<br />int n1;<br />int p2;<br /><br />System.out.println("\tWelcome to ");<br />System.out.println("*******SHINE IT Training Centre*******");<br />System.out.println("**Please login before u calculate**");<br /><br />do<br />{<br />System.out.println("Enter user name: ");<br />name=stdin.readLine();<br />n1=Integer.parseInt(name);<br />System.out.println("Enter password: ");<br />pwd=stdin.readLine();<br />p2=Integer.parseInt(pwd);<br /><br />//System.out.println("Incorrect input!!");<br />} while ((name!="2208")&&(pwd!="1234"));<br /><br /><br />System.out.println("Successful Login!!");<br /><br />}<br />}<br />
Posted

1 solution

eigther change

while ((name!="2208")&&(pwd!="1234"));

to

while ((!name.equals("2208"))&&(!pwd.equals("1234")));

or

while ((n1!=2208)&&(p2!=1234));

;-P ;-P ;-P ;-P
 
Share this answer
 


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900