Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the Code in Java Below is the sample code and guidelines Password Strength Programming challenge description: Write a function that uses regular expressions to

Write the Code in Java Below is the sample code and guidelines

Password Strength

Programming challenge description:

Write a function that uses regular expressions to determine a password's strength.

A valid password for this challenge is a UTF-8 encoded string consisting of a minimum of 6 and a maximum of 25 characters. The accepted range of characters is [U+0021, U+007A] in the Basic Latin Unicode block.

Use the following rules to determine the password strength:

  1. A strong password must have at least one lowercase letter [U+0061, U+007A], one uppercase letter [U+0041, U+005A], one digit [U+0030, U+0039], and one special character (all other characters from the valid range in the Basic Latin block). The length of a strong password must be at least 10 characters.
  2. The rule for a password of medium strength is the same as for strong, except it will not contain special characters and its length must be greater or equal to 8 characters. A password with the special character but shorter than 10 characters has a medium strength. For example, iT*2spX*8 is of medium strength.
  3. All other valid passwords are weak.

All value ranges in the above description are inclusive.

Input:

A string containing a password. For example:

Nufu&YM21S 

Output:

Print out the password's strength: strong, medium, or weak.

Print invalid if the password is not valid.

Test 1

Test InputDownload Test 1 Input

Nufu&YM21S

Expected OutputDownload Test 1 Input

strong

Test 2

Test InputDownload Test 2 Input

iT*2spX*8

Expected OutputDownload Test 2 Input

medium

Test 3

Test InputDownload Test 3 Input

gZAGel

Expected OutputDownload Test 3 Input

weak

Test 4

Test InputDownload Test 4 Input

2N# 9k

Expected OutputDownload Test 4 Input

invalid

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets;

public class Main { /** * Iterate through each line of input. */ public static void main(String[] args) throws IOException { InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8); BufferedReader in = new BufferedReader(reader); String line; while ((line = in.readLine()) != null) { System.out.println(line); } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2017 Skopje Macedonia September 18 22 2017 Proceedings Part 3 Lnai 10536

Authors: Yasemin Altun ,Kamalika Das ,Taneli Mielikainen ,Donato Malerba ,Jerzy Stefanowski ,Jesse Read ,Marinka Zitnik ,Michelangelo Ceci ,Saso Dzeroski

1st Edition

3319712721, 978-3319712727

More Books

Students also viewed these Databases questions