Coding Exercise: While Loop

Think of a real-world scenario where a repetitive task needs to be performed until a certain condition is met. Write a Java program that uses a while loop to handle this task.

Example:

Password Validation
Continuously prompt the user to enter a password.
Check if the password meets certain criteria (e.g., length, special characters).
Stop when the user enters a valid password.

Pseudocode:

BEGIN

WHILE true

PROMPT user to enter a password

READ user input INTO password

IF password meets criteria THEN

DISPLAY “Password is valid”

BREAK the loop

ELSE

DISPLAY “Password is invalid. Please try again.”

END IF

END WHILE

END