Question
(Java) Do-While Loop: Password Formatting Write a program that simulates password creation, where you collect the user's input for their password and validate whether or
(Java) Do-While Loop: Password Formatting
Write a program that simulates password creation, where you collect the user's input for their password and validate whether or not that password is valid, according to certain conditions. If the user's input password does not satisfy the conditions, continue to ask for a password until it does. You should also include a count to keep track of the total number of attempts the user makes to match the correct formatting (i.e., the number of times we loop through the prompt). The conditions are as follows: - The password is at least 5 characters, but no more than 15 characters. - The password must contain at least one uppercase letter. Try to solve this problem using a do-while loop.
1
int count;
2
// IMPORTANT: You do not have to define the main class! You do not have to define count, either.
3
// Just initialize it (to 0) and increment it within your loop.
4
// You do not need to import java.util.Scanner, it is already imported.
5
6
7
System.out.println("Total number of attempts: " + count);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started