in java Integer numVals is read from input and integer array userCounts is declared with size numVals. Then, numVals integers are read from input and stored into userCounts. Output all elements of userCounts in reverse order, following each element with a space, including the last. After the final output, end with a newline. Ex: If the input is 4 54 56 75 7 then the output is: Array contents in reverse: 7 75 56 54 Note: The loop should start with i = userCounts.length - 1 and end with i = 0. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20     import java.util.Scanner;   public class UserLog { publicstaticvoidmain(String[] args) { Scannerscnr=newScanner(System.in); intnumVals; inti;   numVals=scnr.nextInt(); int[] userCounts=newint[numVals];   for (i=0; i<userCounts.length; ++i) { userCounts[i] =scnr.nextInt(); } System.out.print("Array contents in reverse: ");   /* Your code goes here */   } }

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 19RQ
icon
Related questions
Question

in java

Integer numVals is read from input and integer array userCounts is declared with size numVals. Then, numVals integers are read from input and stored into userCounts. Output all elements of userCounts in reverse order, following each element with a space, including the last. After the final output, end with a newline.

Ex: If the input is

4 54 56 75 7

then the output is:

Array contents in reverse: 7 75 56 54

Note: The loop should start with i = userCounts.length - 1 and end with i = 0.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
 
import java.util.Scanner;
 
public class UserLog {
publicstaticvoidmain(String[] args) {
Scannerscnr=newScanner(System.in);
intnumVals;
inti;
 
numVals=scnr.nextInt();
int[] userCounts=newint[numVals];
 
for (i=0; i<userCounts.length; ++i) {
userCounts[i] =scnr.nextInt();
}
System.out.print("Array contents in reverse: ");
 
/* Your code goes here */
 
}
}
 
 
 
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT