In a new class Loopy write a loop that reads ten numbers and

In a new class, Loopy, write a loop that reads ten numbers and stores them in an array. Then write a second loop that displays the ten numbers in the opposite order from which they were entered.

Solution

Loopy.java

import java.util.Scanner;


public class Loopy {

  
   public static void main(String[] args) {
       int a[] = new int[10];
       Scanner scan = new Scanner(System.in);
       System.out.println(\"Enter 10 integers: \");
       for(int i=0; i<a.length; i++){
           a[i] = scan.nextInt();
       }
       System.out.println(\"The ten numbers in the opposite order: \");
       for(int i=a.length-1; i>=0; i--){
           System.out.println(a[i]);
       }

   }

}

Output:

Enter 10 integers:
1
2
3
4
5
6
7
8
9
10
The ten numbers in the opposite order:
10
9
8
7
6
5
4
3
2
1

In a new class, Loopy, write a loop that reads ten numbers and stores them in an array. Then write a second loop that displays the ten numbers in the opposite o

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site