I have been trying to create a program that outputs four arrays created with random ints doubles chars and booleans. It will compile but when I run still gives me the same variables which have nothing to do with my input at all, but my char array works perfectly.
import java.util.Scanner;
import java.util.Random;
public class Lab12b
{
static Scanner input = new Scanner(System.in);
static Random rng = new Random();
static int intList[];
static double dblList[];
static char charList[];
static boolean booList[];
public static void main (String[] args)
{
System.out.println("------------------------------------------------------------");
System.out.println("================ Main Driver Lab 12B =======================");
System.out.println("------------------------------------------------------------");
System.out.println();
System.out.print("How many random variables would you like? ===> ");
int max = input.nextInt();
System.out.println();
System.out.println();
intList = new int[max];
dblList = new double[max];
charList = new char[max];
booList = new boolean[max];
createList();
printList();
}
//creating random variables for each slot in the array
public static void createList()
{
for(int i=0;i<intList.length;i++)
{
intList[i] = rng.nextInt() + 65;
dblList[i] = rng.nextDouble();
charList[i] = (char)( rng.nextInt(26)+65);
booList[i] = rng.nextBoolean();
}
}
//printing out the newly created arrays with their variables
public static void printList()
{
System.out.println("------------------------------------------------------------");
System.out.println("===================== Display List =========================");
System.out.println("------------------------------------------------------------");
System.out.println();
System.out.println(intList);
System.out.println();
System.out.println(dblList);
System.out.println();
System.out.println(charList);
System.out.println();
System.out.println(booList);
System.out.println();
System.out.println();
}
}