004-005-006

While Loop: Password Retry

Easy

Problem Description

While Loop: Password Retry

Learning Objective: Implement processing that repeats until condition changes using while loop

Repeat password input until correct value entered. Implement authentication loop using while loop.

Input

Line 1 onwards: Password attempts (string, multiple lines possible)

Output

When incorrect:

Incorrect. Please try again.
```java
When correct:
```java
Authentication successful!
```java

Correct password: "secret".

Test Cases

※ Output examples follow programming industry standards

Input:
wrong
secret
Expected Output:
Incorrect. Please try again.
Authentication successful!
Input:
secret
Expected Output:
Authentication successful!
Input:
abc
123
secret
Expected Output:
Incorrect. Please try again.
Incorrect. Please try again.
Authentication successful!
❌ Some tests failed
❌ エラー発生

Your Solution

Current Mode: My Code
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here

sc.close();
}
}
0 B / 5 MB

You have 9 free executions remaining