Home / Expert Answers / Computer Science / write-a-program-that-reads-a-list-of-integers-and-outputs-those-integers-in-reverse-the-input-begin-pa550

(Solved): Write a program that reads a list of integers and outputs those integers in reverse. The input begin ...



Write a program that reads a list of integers and outputs those integers in reverse. The input begins with an integer indicating the number of integers that follow. For coding simplicity, follow each output integer by a comma, including the last one. Assume that the list will always contain fewer than 20 integers. Ex: If the input is: Enter list elements, beginning with the number of elements, separated by space: 5 4 3 6 2 1 the output is: 1,2,6,3,4, To achieve the above, first read the integers into an array. Then output the array in reverse. import java.util.Scanner; public class NumbersReversed{ public static void main(String[] args) { Scanner scnr = new Scanner(System.in); // add scanner print prompt // List of numElement integers specified by the user: int[] userList = new int[20]; // Number of integers in user's list: int numElements; // Add more variables as needed // Input begins with number of integers that follow: numElements = scnr.nextInt(); /* Type your code here. */ } } Save your file as NumbersReversed.java. Make sure it compiles and runs without errors



We have an Answer from Expert

View Expert Answer

Expert Answer


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe