import java.util.Scanner;
public class MultiPasswordGen{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Please insert the size of your password.\n");
int passlength = input.nextInt();
System.out.print("Would you like to have multiple passwords printed? (0 = No, X = Amount)\n");
int passmulti = input.nextInt();
password(passlength, passmulti);
}
public static void password(int length, int quantity){
int i,k;
if(length <= 0)
length = (int)(Math.random() * 50);
if(quantity <= 0)
quantity = 1;
int[][] password = new int[length][quantity];
for(k = 0; k < quantity; k++){
for(i = 0; i < length; i++){
switch((int)(1 + (Math.random() * 3))){
case 1:
int offsetLarge = 'Z'-'A';
int letterLarge = (int)('A' + (Math.random() * offsetLarge));
password[i][k] = letterLarge;
break;
case 2:
int offsetSmall = 'z'-'a';
int letterSmall = (int)('a' + (Math.random() * offsetSmall));
password[i][k] = letterSmall;
break;
case 3:
int offsetNumber = '9'-'0';
int number = (int)('0' + (Math.random() * offsetNumber));
password[i][k] = number;
break;
}
}
}
for(k = 0; k < quantity; k++){
System.out.print("Your password: ");
for(i = 0; i < password.length; i++){
System.out.print((char)password[i][k]);
}
System.out.print("\n");
}
}
}