Advertisement
MrDoyle

comparing strings to user input

Oct 14th, 2020
1,889
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner input = new Scanner(System.in);
  7.  
  8.         String answer;
  9.         int loop = 1;
  10.  
  11.         while (loop ==1) {
  12.             System.out.println("Please enter your password");
  13.             answer = input.next();
  14.             if (answer.equals("word")) {
  15.                 System.out.println("You a winner!");
  16.                 loop = 0 ;
  17.             } else {
  18.                 System.out.println("You not a winner");
  19.             }
  20.  
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement