![zach8782](/avatars/44608.jpg)
zach8782
05.02.2021 •
Computers and Technology
Some websites impose certain rules for passwords. Suppose the password rules are as follows:
1. A password must have at least eight characters.
2. A password must consist of only letters and digits.
3. A password must contain at least two digits.
Write a program 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. The password is passed to the string variable p in this method. Inside the method do the following. Here are four sample runs:
Sample 1
1) Enter your password: My password18
Invalid password
Sample 2
Enter your password: pass18
Invalid password
Sample 3
Enter your password: password
Invalid password
Sample 4
Enter your password: password18
Valid password
Create a method AtLeast8 outside the main method with the header provided in the problem description.
i) If the length of p is less than 8 then return false, otherwise return true.
Solved
Show answers
More tips
- H Health and Medicine Get Rid of Warts: Simple and Effective Ways...
- S Style and Beauty How to Choose the Perfect Hair Color?...
- C Computers and Internet Best iPad Games: Our Opinion...
- A Animals and plants Man s Best Friend: Which Dog Breed Is the Most Friendly?...
- H Health and Medicine 10 Simple Techniques on How to Boost Your Mood...
- G Goods and services How to Choose the Right High Chair for Your Baby?...
- S Style and Beauty Learn how to tie a keffiyeh on your head like a pro...
- S Style and Beauty How to braid friendship bracelets?...
Answers on questions: Computers and Technology
- M Mathematics Choose the best answer to the following question. explain your reasoning. one hundred students take a chemistry exam. all but two of the students score between 55...
- M Mathematics Choose the best answer to the following question. explain your reasoning. the distribution of wages at a company is right-skewed with outliers at high values. assuming...
- M Mathematics 13. let r be the set of all real numbers. is (r , r, o)) a partition of r? explain your answer to get credit. 14. let a=(a, b, c, d). find the power set of a, pa...
- M Mathematics 1)assume you have a balance of $1,500 on a credit card. a. if the credit card has an annual interest rate of 13.6% and only the minimum monthly payment of $25 is made,...
- M Mathematics Acell of some bacteria divides into two cells every 10 minutes.the initial population is 3 bacteria. (a) find the size of the population after t hours (function of...
- M Mathematics Ingrid wants to buy a ? $20,000 car in 5 years. how much money must she deposit at the end of each quarter in an account paying 5.4? % compounded quarterly so that...
- M Mathematics Dave wants to purchase 25 pounds of party mix for a total of ? $60. to obtain the? mixture, he will mix nuts that cost ? $4 per pound with pretzels that cost ? $2...
- M Mathematics Amanufacturing company makes two types of water skis, a trick ski and a slalom ski. the trick ski requires 10 labor-hours for fabricating and 1 labor-hour for finishing....
- M Mathematics Suppose you have a student loan of $120,000 with an apr of 9% for 30 years. if you decide you would like to pay off the loan in 20 years instead of 30, how much more...
- M Mathematics In a certain city, the unemployment rate was 20% last year and this year it is 30%. which of the following statements is correct? o a. in absolute terms, the unemployment...
Ответ:
"The Revolution eats its own children"