Question: Java Name Generally web sites impose certain rules for passwords. Complete a program that checks whether string is a valid password. Suppose the password rule

Java
Java Name Generally web sites impose certain rules for passwords. Complete a
program that checks whether string is a valid password. Suppose the password
rule is as follows: A password must have at least eight characters.

Name Generally web sites impose certain rules for passwords. Complete a program that checks whether string is a valid password. Suppose the password rule is as follows: A password must have at least eight characters. A password consists of only letters and digits. A password must contain at least two digits. Test your program with the following passwords: passwords pass58 password_95 password 2013 Your program will display the password and a message indicating whether it is valid or invalid. You need to create a NetBeans project called "FirstNameLastNameExam1": 1. Open the file "Exam 1 A.java" which can be downloaded from the x drive. Add this file to your NetBeans project. 2. Analyze the code that I have provided. 3. Provide your code in the locations indicated by comments in the source file. 4. I have declared a String called s. 5. I have created 4 String objects containing test passwords 6. Use a Random object to generate a random integer between 0 and 3 inclusive and store that value in an integer variable called num. 7. Use that value to select a string to test for validity. (Use a nested for switch construct to assign the string to variables). 8. Invoke method isValidPassword and display the password and a message as to whether it is valid or invalid. 9. I have provided the header for method isValidPassword. 10. You need to provide the code for method isValidPassword. I have provided comments in the code to help you structure your solution. 11. Test your program by setting up a for loop which will iterate 20 times, displaying the randomly generated password and message. Deliverables 1. Copy your results to the bottom of your source file. Print your results (MAKE SURE YOUR THAT NO STATEMENTS IN YOUR PROGRAM GO BEYOND THE RED LINE ON THE RIGHT). Be sure to include your name in both your source code as a comment and in your output as a line of output. 2. Submit a digital copy of your project. public class Exam1A { public static void main(String[] args) String s; 7/ Create 4 strings String str1 = new String("passwords"); String str2 = new String("pass58"); String str3 - new String("password_95") String str4 = new String("password 2013"); //Randomly generate an integer value between 0 and 3 inclusive //Use that integer to designate the string to be tested //and assign that //string to variable s. (o gets stri, 1 gets str2, etc) //invoke method isValidPassword passing in the selected string //display the password and a message as to whether it //is valid or invalid /ote that method isValidPassword returns a boolean value /** Check if a string is a valid password */ public static boolean isValidPassword(String s) //check for only letters and digits? //Use methods from the String class and the //Character wrapper class 7/You will need to iterate through the string 7/and check each character //returning false if the letters and digits rule is violated //Check length //return false if the length rule is violated //Count the number of digits //return false if the number of digits rule is violated

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!