Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. // Application Reverse reads numbers into an array
  2. // and prints them out in reverse order.
  3. import java.util.Scanner;
  4. import java.io.*;
  5. public class Reverse
  6. {
  7. public static void main(String[] args) throws IOException
  8. {
  9. final int MAX = 10;
  10. Scanner inFile = new Scanner(new FileReader("Reverse.dat"));
  11. int[] numbers;
  12. numbers = new int[MAX];
  13.  
  14. int value;
  15. int index;
  16. for (index = 0; index < numbers.length; index++)
  17. {
  18. numbers[index]=inFile.nextInt();
  19. }
  20. for (index = MAX - 1; index >= 0; index--)
  21. System.out.println(numbers[index]);
  22. inFile.close();
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement