Created
February 18, 2015 02:01
-
-
Save ragmha/5f2b916bbe0ed0361d5c to your computer and use it in GitHub Desktop.
Ex22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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){ | |
// Write your code here | |
System.out.print("Type the password: "); | |
String password1 = reader.nextLine(); | |
if(password1.equals(password)){ | |
System.out.println("Right!"); | |
System.out.print("\n"); | |
System.out.println("The secret is: jryy qbar!"); | |
}else { | |
System.out.println("Wrong!"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment