1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
nasty-shy [4]
3 years ago
11

Write a program with a method called passwordCheck to return if the string is a valid password. The method should have the signa

ture shown in the starter code.
The password must be at least 8 characters long and may only consist of letters and digits. To pass the autograder, you will need to print the boolean return value from the passwordCheck method.
Hint: Consider creating a String that contains all the letters in the alphabet and a String that contains all digits. If the password has a character that isn’t in one of those Strings, then it’s an illegitimate password!
Coding portion:
public class Password
{
public static void main(String[] args)
{
// Prompt the user to enter their password and pass their string
// to the passwordCheck method to determine if it is valid.
}
public static boolean passwordCheck(String password)
{
// Create this method so that it checks to see that the password
// is at least 8 characters long and only contains letters
// and numbers.
}
}
Computers and Technology
1 answer:
Ber [7]3 years ago
6 0

Answer:

import java.util.regex.*;

import java.util.Scanner;

public class Password

{

  public static void main(String[] args) {

  Scanner input = new Scanner(System.in);

  System.out.println("Please enter the Password. \n");

  String passwordString = input.next();

  System.out.println(passwordCheck(passwordString));

  }

  public static boolean passwordCheck(String password){

  if(password.length()>=8 && password.matches("[a-z0-9A-Z]+")){

  return true;

  }

  else{

  return false;

  }

  }

}

Explanation:

The Java class "Password" is used by the program to make an instance of the password object and check its validity with the passwordChecker method defined within the Password class. The passwordChecker method only matches alphanumeric passwords, that is, passwords with alphabets and numbers. If a non-alphanumeric character is encountered, the boolean value false is returned.

You might be interested in
The physical parts of Computer are kwon as<br>​
Anna35 [415]

Answer:

Computer hardware

Explanation:

Computer hardware includes the physical parts of a computer, such as the case,central processing unit (CPU), monitor, mouse, keyboard, computer data storage, graphics card, sound card, speakers and motherboard.

3 0
3 years ago
What kind of software is Microsoft Outlook??
NNADVOKAT [17]

Answer:

Email software

Explanation:

8 0
3 years ago
Read 2 more answers
Potential Energy and Kinetic Energy both mean "energy in motion" True or False​
Irina18 [472]

Answer:

false

Explanation:

pretty sure energy in motion is only for kinetic energy

4 0
3 years ago
Read 2 more answers
What should you do first when designing a program?
Nady [450]

Answer: talk about da progrm

Explanation:

6 0
3 years ago
Read 2 more answers
Naynar kis dhrm se sambandhit hai​
Inessa05 [86]

Answer:

Islam dharm se sabandhit

5 0
3 years ago
Read 2 more answers
Other questions:
  • Write a program that calls fork(). Before calling fork(), have the main process access a variable (e.g., x) and set its value to
    5·1 answer
  • You are asked to optimize a cache design for the given references. Th ere are three direct-mapped cache designs possible, all wi
    7·1 answer
  • Jane is debugging a code consisting of 25 lines. The code starts executing at line 11. At line 13, the code calls another method
    10·2 answers
  • ​In sql server, the cursor property ____________________ means that the cursor is used for retrieval purposes only.
    9·1 answer
  • If a driving who is under the age of 21 is stopping by a law enforcement officer and shown to here a bal of .02 or greater, he o
    14·1 answer
  • 3. Find the product of (a² +3a+5) x (a+7)​
    7·1 answer
  • In his article “is google making up stupid” Nicholas Carr uses a metaphor to suggest that
    11·2 answers
  • Which value can be entered to cause the following code segment to display the message "That number is acceptable."? ____.
    15·1 answer
  • How are envelopes and letterheads different
    7·1 answer
  • The __Option carries out the commands one at a time. O Step-by-Step Run Command Open Command​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!