Assignment
University
California State UniversityCourse
COMP 182 | Data Structures and Program Design and LabPages
2
Academic year
2023
KauK
Views
24
import java.util.Scanner; public class Lab1_1 { public static void main ( String [] args ) { Scanner scnr = new Scanner ( System . in ); // add scanner print prompt System . out . println ( "Enter integers separated by a space:" ); // 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. */ //Populate userList with integers from input for ( int i = 0 ; i < numElements; i++) { userList[i] = scnr . nextInt (); } //Print the userList in reverse for ( int i = numElements- 1 ; i >= 0 ; i--) { System . out . print (userList[i] + ", " ); } } }
Java Program: Lab Assignment 1.1 - Output Numbers in Reverse
Please or to post comments