Create a loop that counts the number of digits in p

Assignment Help Computer Engineering
Reference no: EM132173770

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 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

You 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 AtLeast8

4. 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 LetterOrDigit

5. 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.6

ii) 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 AtLeast2Digits

6. 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.

Reference no: EM132173770

Questions Cloud

What is the required sample size : What is the required sample size, if the researcher wants to be accurate to within 0.5 minutes at a 95% level of confidence?
Determine the point estimate of the population proportion : Determine the point estimate of the population proportion lower bound=0.342, upper bound=0.918, n=1200
Present all the relevant hypotheses : Completed a factorial experiment to see if scores on exams are affected by gender and teaching methods. The data system appears below.
Find the p-value for your test statistic : Solve using the Traditional Method. Find the p-value for your test statistic.
Create a loop that counts the number of digits in p : 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.
Average movie budget : Test to determine if action movies cost more than the average movie budget. Solve using the Traditional Method. Use a= .05.
Write the python statement that will print the number : Write the Python statement that will print the number of arguments that were provided on the command line.
??what proportion of 1040r tax forms : ??What proportion of 1040R tax forms will be completed in less than 97 minutes?
Write a function that takes one string parameter : Write a function named wordLenghts() that takes one string parameter (text)you may assume that the given text contains only letters.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd