PLEASE HELP ME FIX THE PROBLEM import java.util.Scanner; //import scanner input class Main { public static void main

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

PLEASE HELP ME FIX THE PROBLEM import java.util.Scanner; //import scanner input class Main { public static void main

Post by answerhappygod »

PLEASE HELP ME FIX THE PROBLEM
import java.util.Scanner; //import scanner input
class Main {
public static void main(String[] args) {
//Input number of password to
make
Scanner scan = new
Scanner(System.in);
System.out.println("Number of random
password to make:");

//Input the length of password
int number = scan.nextInt();
System.out.println("The length of the
character to make:");
int length = scan.nextInt();

String[] randomPassword = new
String[number];

//loop
for(int i = 0; i < number; i++)
{
//Generate one
random password
for(int i = 0; i
< length; i++) {

randomPassword += randomCharacter();
}
//Add to array of
password
randomPassword =
randomPassword;
}
printPassword(randomPassword); //print
array of password


System.out.println(getStrength(length)); //print password
strength
}

public static String getStrength(int length) {
//Conditional for the password
strength
if (length < 6) {
return
"short";
} else if (length < 12) {
return
"medium";
} else {
return
"strong";
}
}

public static void printPassword(String[] arr)
{
for(int i = 0; i < arr.length;
i++) {

System.out.println(arr);
}
}


public static char
randomCharacter() {

int x =
(int)(Math.random()*50);
// Conditional of the
length to make
if (x<=8) {
int a
= x + 48;
return
(char)(a);
} else {
int a
= x + 65;
return
(char)(a);
}
}
}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply