Answer to Question #283884 in Java | JSP | JSF for Archie

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.


1
Expert's answer
2021-12-31T01:41:48-0500


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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog