7. (6 marks) Write a program to ask user to enter an integer that represents the number of elements, then generate an Ar

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: 899558
Joined: Mon Aug 02, 2021 8:13 am

7. (6 marks) Write a program to ask user to enter an integer that represents the number of elements, then generate an Ar

Post by answerhappygod »

7 6 Marks Write A Program To Ask User To Enter An Integer That Represents The Number Of Elements Then Generate An Ar 1
7 6 Marks Write A Program To Ask User To Enter An Integer That Represents The Number Of Elements Then Generate An Ar 1 (50.39 KiB) Viewed 1 time
7. (6 marks) Write a program to ask user toenter an integer that represents the number of elements, thengenerate an ArrayList containing elements which are all randomintegers in range [50, 199] (50 and 199 are both included), andfinally display index, element value and triple element value inthe reverse index order.
REQUIREMENTS
Example of the program output:
Example 1:
Enter the number of elements: 5
Index Element Triple
4 126 378
3 97 291
2 53 159
1 133 399
0 81 243
Example 2:
Enter the number of elements: 12
Index Element Triple
11 198 594
10 185 555
9 158 474
8 75 225
7 168 504
6 62 186
5 58 174
7. (6 marks) Write a program to ask user to enter an integer that represents the number of elements, then generate an ArrayList containing elements which are all random integers in range [50, 199] (50 and 199 are both included), and finally display index, element value and triple element value in the reverse index order. REQUIREMENTS • The user input is always correct (input verification is not required). Your code must use ArrayList. Your program must use only printf(...) statements to adjust the alignment of your output. Your code must display the index in reverse order. Your output must be displayed with the same alignment as the example (the text in bold indicates the user input). Example of the program output: Example 1: Enter the number of elements: 5 Index Element Triple 4 126 378 3 97 291 2 53 159 1 133 399 0 81 243 Example 2: Enter the number of elements: 12 Index Element Triple 11 198 594 10 185 555 158 474 75 225 168 504 62 186 58 174 HO 9896 in 7 5
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply