Question #283884

Write a program to create a single dimension array to store 15 numbers. Then create another array to store those numbers in reverse order. Then display values of both the array in to different consecutive columns.


Expert's answer



import java.util.Scanner;


public class App {


	/**
	 * The start point of the program
	 * 
	 * @param args
	 * 
	 */
	public static void main(String[] args) {
		Scanner keyBoard = new Scanner(System.in);
		int numbers[] = new int[15];
		int numbersReverseOrder[] = new int[15];


		for (int i = 0; i < 15; i++) {
			System.out.print("Enter the number " + (i + 1) + ": ");
			numbers[i] = keyBoard.nextInt();
		}
		int k=0;
		for (int i = 14; i >= 0; i--) {
			numbersReverseOrder[k]=numbers[i];
			k++;
		}
		System.out.println("");
		for (int i = 0; i < 15; i++) {
			System.out.printf("%-5d%-5d\n", numbers[i], numbersReverseOrder[i]);
		}


		keyBoard.close();
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS