In: Computer Science
REQUIREMENTS
Example of the program output:
Example 1:
Enter the number of elements: 5
Index Element
4 129
3 138
2 134
1 98
0 84
Example 2:
Enter the number of elements: 12
Index Element
11 109
10 80
9 122
8 84
7 142
6 114
5 114
4 111
3 82
2 91
1 132
0 113
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
public class RandomList {
public static void main(String[] args) {
Scanner sc = new
Scanner(System.in);
System.out.print("Enter the number
of elements: ");
int n = sc.nextInt();
Random r = new Random();
ArrayList<Integer>list = new
ArrayList<>();
for(int i=0;i<n;i++)
list.add(r.nextInt(200));
System.out.println("Index\tElement");
for(int
i=list.size()-1;i>=0;i--)
System.out.println(i+"\t"+list.get(i));
}
}