004-005-001

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"

## Examples

### Example 1: Success After One Failure
Input:
```java
wrong
secret
```java
Output:
```java
Incorrect. Please try again.
Authentication successful!
```java

### Example 2: Success on First Try
Input:
```java
secret
```java
Output:
```java
Authentication successful!
```java

### Example 3: Success After Multiple Failures
Input:
```java
abc
123
secret
```java
Output:
```java
Incorrect. Please try again.
Incorrect. Please try again.
Authentication successful!

Test Cases

※ Output examples follow programming industry standards

Input:
wrong
secret
Expected Output:
Incorrect. Please try again.
Authentication Success!
Input:
secret
Expected Output:
Authentication Success!
Input:
abc
123
secret
Expected Output:
Incorrect. Please try again.
Incorrect. Please try again.
Authentication Success!
❌ 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 6 free executions remaining