fork(2) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. String passwrd = "password";
  13.  
  14. String inputPassword;
  15. boolean b = true;
  16. Scanner sc = new Scanner(System.in);
  17. do {
  18.  
  19. System.out.print("Please Input Password ");
  20.  
  21. inputPassword = sc.nextLine();
  22.  
  23. if (inputPassword.equals(passwrd)) {
  24.  
  25. System.out.println("Password Accepted, Loading Archive...");
  26. b = false; //not continue the loop
  27. } else {
  28.  
  29. System.out.println("Invalid Password");
  30. b = true; // continue the loop
  31.  
  32. }
  33.  
  34. } while (b);
  35.  
  36. }
  37. }
Success #stdin #stdout 0.13s 321280KB
stdin
akk
password
stdout
Please Input Password Invalid Password
Please Input Password Password Accepted, Loading Archive...