JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*Write a program that takes in a string as input and evaluates it as a valid password. The password is valid if it has at a minimum 2 numbers, 2 of the following special characters ('!', '@', '#', '$', '%', '&', '*'), and a length of at least 7 characters.
If the password passes the check, output 'Strong', else output 'Weak'.
*/
import java.util.Scanner;
public class Program{
public static void main(String[] args) {
boolean flag = true;
Scanner obj = new Scanner(System.in);
String password = obj.nextLine();
for(int i=0;i<password.length();i++) {
char ch = password.charAt(i);
int a = (int) ch;
if(!((a>=64 && a<=90)||(a>=97 && a<=122)||(a>=48 && a<=57)||(a>=35 && a<=38)||(a==33)||(a==42))) {
System.out.println("Weak");
System.exit(1);
}
}
numbercheck obj1 = new numbercheck();
int number = obj1.numbercheck(password);
charcheck obj2 = new charcheck();
int charnum = obj2.charcheck(password);
if(number>=2&&charnum>=2&&password.length()>=7&&flag==true)
System.out.println("Strong");
else
System.out.println("Weak");
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run