I have to make a program using a one-dimensional array that accepts as input an integer value asking for the number of elements for each list. This will be used to generate random numbers (10-99) for the one-dimensional arrays (list a and list b). The program will compute for the product and store it in another array (list c).
Example of an output that I should get should be:
Input the number of elements: 3
List A [space] List B [space] List C
34 [---space---] 15 [-space-] 510
64 [---space---] 25 [-space-] 1600
11 [---space---] 50 [-space-] 550
But the program I did is having errors in my last statement saying that: cannot find the symbol i and j
Can you tell me where I got it wrong?
Here's my program:
import java.util.* ; public class onedimensional_array{ public static void main(String[] args){ Random rand = new Random(); Scanner kbd = new Scanner(System.in); System.out.print("Input the number of elements: "); int elements = kbd.nextInt(); System.out.println("List A" + " " + "List B" + " " + "List C"); int listA[] = new int[elements]; int listB[] = new int[elements]; for(int i=0; i<elements; i++){ listA[i] = 10 + rand.nextInt(90); } for(int j=0; j<elements; j++){ listB[j] = 10 + rand.nextInt(90); } System.out.println(listA[i] + " " + listB[j] + " " + listA[i]*listB[j]); } }