Answer to Question #285196 in Java | JSP | JSF for Alek

Question #285196

Write a program to store 25 numbers in a Single dimension array then display  numbers in one column and even or odd Message in another column with appropriate heading as follows:

Number    Message 

10           Even

12           Even

101          Odd


1
Expert's answer
2022-01-06T02:00:45-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[25];
		for (int i = 0; i < 25; i++) {
			System.out.print("Enter the number " + (i + 1) + ": ");
			numbers[i] = keyBoard.nextInt();
		}
		System.out.printf("%-15s%-15s\n", "Number", "Message");
		for (int i = 0; i < 25; i++) {
			if (numbers[i] % 2 == 0) {
				System.out.printf("%-15d%-15s\n", numbers[i], "Even");
			} else {
				System.out.printf("%-15d%-15s\n", numbers[i], "Odd");
			}
		}
		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