Computers and Technology

Using the program Eclipse IDE for Java Developers, Version: Neon.2 Release (4.6.2)Problem Description: Some websites impose certain rules for passwords. Suppose password rules are as follows: 1. A password must have at least eight characters. 2. A password consists of only letters and digits. 3. A password must contain at least two digits. Write a program with class name CheckPassword that prompts the user to enter a password and displays Valid password if the rules are followed or Invalid password otherwise. Create three methods (headers given below) to check the three rules. public static boolean AtLeast8(String p) public static boolean LetterOrDigit(String p) public static boolean AtLeast2Digits(String p)For example, method AtLeast8 will return true if there are at least eight characters in the password otherwise it will return false. Here are four sample runs:Sample 1: Enter your password: My password18 Invalid passwordSample 2: Enter your password: pass18 Invalid password Sample3: Enter your password: password Invalid password Sample4: Enter your password: password18 Valid passwordYou can use the following steps in your code: System. out. print("Enter your password: ");1. Store the user entry in String variable named password using nextLine() method.2. Create three boolean variables isAtLeast8, isLetterDigit, and isAtLeast2Digits and assign the output of the corresponding methods to these boolean variables. For example, boolean isAtLeast8 = AtLeast8(password);3. If each boolean variable is true then display Valid password otherwise display Invalid password. //Method AtLeast84. Create a method AtLeast8 outside the main method with the header provided in the problem description. The password is passed to the string variable p in this method. Inside the method do the following. i) If the length of p is less than 8 then return false, otherwise return true. //Method LetterOrDigit5. Create a method LetterOrDigit outside the main method with the header provided in the problem description. The password is passed to the string variable p in this method. Inside the method do the followings. i) Create a loop that checks whether each character in p is a letter or a digit. To check this use the in-built methods Character. isLetterOrDigit(p. charAt(index)). The method isLetterOrDigit returns true if p. charAt(index) is a letter or digit. See Chapter 4 Table 4.6ii) If a character is not found to be a letter or digit then return false inside the loop, otherwise return true outside the loop. //Method AtLeast2Digits6. Create a method AtLeast2Digits outside the main method with the header provided in the problem description. The password is passed to the string variable p in this method. Inside the method do the followings. i) Create an integer variable count and assign zero to it. ii) Create a loop that counts the number of digits in p. The in-built method Character. isDigit(p. charAt(index)) returns true if p. charAt(index) is a digit. Increase count by one when a digit is found. iii) If the count is at least 2 then return true inside the loop, otherwise return false outside the loop.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 22:00, haydonmetzger
Which one of the following identifies the primary a purpose of information classification processes? a. define the requirements for protecting sensitive data. b. define the requirements for backing up data. c. define the requirements for storing data. d. define the requirements for transmitting data.
Answers: 2
image
Computers and Technology, 22.06.2019 19:00, alyssashae1818
Which parts of a presentation should be the most general? a. introduction and conclusion b. introduction and outline c. outline and conclusion d. outline and body
Answers: 1
image
Computers and Technology, 23.06.2019 07:00, sugaree95
What are three software programs for mobile computing?
Answers: 1
image
Computers and Technology, 23.06.2019 15:20, headshotplayzcod
In a game with three frames, where will the objects on layer 1 appear? a. next to the play area b. in the middle of the game c. behind everything else d. in front of everything else
Answers: 1
Do you know the correct answer?
Using the program Eclipse IDE for Java Developers, Version: Neon.2 Release (4.6.2)Problem Descriptio...

Questions in other subjects:

Konu
Social Studies, 28.10.2020 01:00
Konu
Social Studies, 28.10.2020 01:00