Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Scanner; public class PasswordManager { // this method returns true if password matches all criteria public static boolean isPasswordAccepted() { // create a scanner

import java.util.Scanner; public class PasswordManager { // this method returns true if password matches all criteria public static boolean isPasswordAccepted() { // create a scanner class object to take input from user Scanner sc = new Scanner(System.in); // take input from user System.out.print("Enter password: "); String password = sc.next(); // for checking if password length // is minimum 8 or not. if not, return false if (!(password.length() >= 8)) { return false; } // checking digits int count = 0; for (int i = 0; i <= 9; i++) { // convert integer to string String str = String.valueOf(i); if (password.contains(str)) { count = 1; } } // if count = 0, return false if (count == 0) { return false; } // checking letters, i for capital and j for lower letters count = 0; for (int i = 65; i <= 90; i++) { int j = 90; // type casting char c1 = (char) i; char c2 = (char) j; String str1 = String.valueOf(c1); String str2 = String.valueOf(c2); if (password.contains(str1) || password.contains(str2)) { count = 1; } j++; } // if count = 0, return false if (count == 0) { return false; } // checking special characters if (!(password.contains(":") || password.contains(",") || password.contains("!") || password.contains("?"))) { return false; } // otherwise return true return true; } public static void main(String[] args) { // call isPasswordAccepted() method boolean result = isPasswordAccepted(); // if result = true, means password matches the criteria if(result) { System.out.println("The Password is Accepted"); }else { System.out.println("The Password is NOT Accepted"); } }

please can you edit this to encrypt the correct password by adding a loop in java also prints the actual password aswell in java

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

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions

Question

Was there an effort to involve the appropriate people?

Answered: 1 week ago

Question

18. If you have power, then people will dislike and fear you.

Answered: 1 week ago