Home CPSC 220

Array Reversal

 

Objective

To be able to use arrays and iterate through them in Java.
 

Task

For this lab exercise, you are to write a program that reads in a number of positive integers from the user, stores them in an array, and prints them out in the reverse order. The user will enter the numbers one on each line and will use -1 to mark the end. The user will never enter more than 100 numbers.
 

Details


 

Example Run


Enter values (-1 to stop)
: 10
: 20
: 30
: 40
: 50
: 60
: -1
Your values, reversed:
60
50
40
30
20
10

 

Submitting

When your program works, email the code to ifinlay@umw.edu.

Copyright © 2019 Ian Finlayson | Licensed under a Creative Commons Attribution 4.0 International License.