Skip to content

Instantly share code, notes, and snippets.

@ragmha
Created February 18, 2015 02:01
Show Gist options
  • Save ragmha/5f2b916bbe0ed0361d5c to your computer and use it in GitHub Desktop.
Save ragmha/5f2b916bbe0ed0361d5c to your computer and use it in GitHub Desktop.
Ex22
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