Reverse the numbers entered Write a program that reads ten i

(Reverse the numbers entered) Write a program that reads ten integers and displays them in the reverse of the order in which they were read.

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

(Reverse the numbers entered) Write a program that reads ten integers and displays them in the reverse of the order in which they were read.SolutionLoopy.java i

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site