Hi
I tried solving Ex 22. The test compiles and the output was as expected. But it did not pass the test on server.
I dont get whats the error.Could you please help.
I submitted the following code:
import java.util.Scanner;
public class Password {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
String password = "carrot"; // Use carrot as password when running tests.
while(true)
{
System.out.println("Type the password: ");
String x = reader.nextLine();
if(x.equals("carrot"))
{
System.out.println("Right!");
System.out.println("The secret is: jryy qbar!");
}
else
{
System.out.println("Wrong!");
}
System.out.println("The secret is: jryy qbar!");
}
}
}
Hey, the proper place to ask help about code is nowadays our IRC channel and our Google groups. and sharing code is easier when using out pastebin service: In NetBeans, select TMC -> Send code to TMC pastebin. Copy the link you receive and paste it here.
Anyways, now your code prints se secret anyway, not depending on whether the password was entered properly.