Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Password {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String username = scanner.nextLine();
- String password = scanner.nextLine();
- String input = "";
- while (true) {
- input = scanner.nextLine();
- if (input.equals(password)) {
- System.out.println("Welcome " + username + '!');
- break;
- }
- }
- }
- }
- ИЛИ:
- import java.util.Scanner;
- public class Password {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String username = scanner.nextLine();
- String password = scanner.nextLine();
- String input = scanner.nextLine();
- while(!input.equals(password)){
- input = scanner.nextLine();
- }
- System.out.println("Welcome " + username + '!');
- }
- }
- ИЛИ:
- import java.util.Scanner;
- public class Password {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String username = scanner.nextLine();
- String password = scanner.nextLine();
- String input = "";
- while(!(input = scanner.nextLine()).equals(password)){
- }
- System.out.println("Welcome " + username + '!');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement