First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects).Then create a new Java application called "PasswordChecker" (without the quotation marks) that gets a String of a single word from the user at the command line and checks whether the String, called inputPassword, conforms to the following password policy.The password must:Be 3 characters in lengthInclude at least one uppercase characterInclude at least one digitIf the password conforms to the policy, output "The provided password is valid." Otherwise, output "The provided password is invalid because it must be three characters in length and include at least one digit and at least one uppercase character. Please try again."  A loop is not needed for this program.

Question
Asked Oct 14, 2019
4 views

First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects).

Then create a new Java application called "PasswordChecker" (without the quotation marks) that gets a String of a single word from the user at the command line and checks whether the String, called inputPassword, conforms to the following password policy.

The password must:

  • Be 3 characters in length
  • Include at least one uppercase character
  • Include at least one digit

If the password conforms to the policy, output "The provided password is valid." Otherwise, output "The provided password is invalid because it must be three characters in length and include at least one digit and at least one uppercase character. Please try again."  A loop is not needed for this program.

check_circle

Expert Answer

Step 1

Program:

//import header file

import java.util.Scanner;

 

//definition of "PasswordChecker" class

public class PasswordChecker

{

    //definition of main method

    public static void main(String args[])

    {

        //declare an object for the "Scanner" class

        Scanner x = new Scanner(System.in);

 

        //get the password from the user

        System.out.print("Enter the password : ");

        String inputPassword = x.nextLine();

       

        //check the password meets the requirements

        if((inputPassword.length() == 3)&&((inputPassword.charAt(0) >= 'A' && inputPassword.charAt(0) <= 'Z') || (inputPassword.charAt(1) >= 'A' && inputPassword.charAt(1) <= 'Z') || (inputPassword.charAt(2) >= 'A' && inputPassword.charAt(2) <= 'Z'))&&((inputPassword.charAt(0) >= '0' && inputPassword.charAt(0) <= '9') || (inputPassword.charAt(1) >= '0' && inputPassword.charAt(1) <= '9') || (inputPassword.charAt(2) >= '0' && inputPassword.charAt(2) <= '9')))

        {

            //display the statement

            System.out.println("The provided password is valid");

        }

       

        //otherwise

        else

            //display the statement

            System.out.println("The provided password is invalid because it must be three characters in length and include at least one digit and at least one uppercase character. Please try again.");

    }

}

Step 2

Output:

 

...
help_outline

Image Transcriptionclose

Enter the password: De3 The provided password is valid BUILD SUCCESSFUL (total time: seconds)

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: I want to see how one can add 80 elements into an array without manually entering in each element.  ...

A: Given,The name of the first array is numberArray1 and the size of the array is 80.The name of the se...

question_answer

Q: Given the information below, create the fully labeled Crow's Foot ERD using a specialization hierarc...

A: The fully labelled Crow's Foot ERD using a specialization hierarchy is given below. The ERD containU...

question_answer

Q: 2)   Consider the following class   class Department { private: string name; const long locationNo; ...

A: Program descriptionThe class definition has the declarations of the static variables, regular variab...

question_answer

Q: Below is code which defines and creates an Array, myList: int [] myList = new int [5]; //define and ...

A: Writing a java program with class name XXX_Lab75. This class consists of two methods:First method is...

question_answer

Q: Problem 1 consists of multiple parts. You should finish one part and ensure that it works before mov...

A: Hello. Since your question has multiple sub-parts, we will solve first three sub-parts for you. If y...

question_answer

Q: Decrypt the following shift cipher. (Show work) NFRNSIZVZJXSJZSNAJWXNYD'XKNXMJWMFQQ What is the pl...

A: Ceasar cipher:The Ceasar cipher is one of the simplest and oldest known ciphers.In this cipher, each...

question_answer

Q: Create a new file (in Dev C++)  In Lab 2, you created a menu for a simple calculator program. In Lab...

A: Program AlgorithmDeclare the required variables and write a welcome message before starting the menu...

question_answer

Q: Translate the following instructions from Pep/9 machine language: (Describe what each instruction do...

A: Given instructions -D1 FC 15 F1 00 21 90 00 20 F1 00 21 F1 FC 16 00 zzSize of main memory is 216 byt...

question_answer

Q: 1. Write a program in Python named filemaker.py that will be used to store the first name and age of...

A: This python program asks user to enter First name and Age of a number of friends. This program name ...