Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with the code for a valid password. Below is what the instructor wan

ID: 3631665 • Letter: I

Question

I need help with the code for a valid password. Below is what the instructor wants.. Thanks for the help.


Project: Checking Password





Problem Description:

Some Websites impose certain rules for passwords. Write a method that checks whether a string is a valid password. Suppose the password rule is as follows:

Here is the start of the code that she wants us to us



public static boolean isvalid(String password)

{

boolean goodSoFar= True;

int numDigits= 0;

int numLetters = 0;

int numOthers=0;




· A password must have at least eight characters.

· A password consists of only letters and digits.

· A password must contain at least two digits and at least two letters.



Write a program that prompts the user to enter a password and displays "valid password" if the rule is followed or "invalid password" otherwise.



Sample 1

Enter a string for password: wewew43x

valid password



Sample 2

Enter a string for password: 343a

invalid password





Analysis:

(Describe the purpose, processing, input and output in your own words.)























Design:

(Describe the major steps for solving the problem.)



















Testing: (Describe how you test this program)

Explanation / Answer

import java.util.Scanner; public class ValidPassword { public static void main (String[] args) {String password; Scanner input = new Scanner(System.in); System.out.print("Enter a string for password: "); password=input.next(); if(isvalid(password)) System.out.println("valid password"); else System.out.println("invalid password"); } public static boolean isvalid(String password) {boolean goodSoFar=true; int numDigits= 0; int numLetters = 0; int numOthers=0; if(password.length()