Write a program using one-dimensional array that determines the highest value among the five input values from the keyboard and prints the difference of each value from the highest.
the result would be:
Enter ten numbers:
8 9 7 10 25 30 69 101 1001 798
Here is the list of Even number/s:
8 10 30 798
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[10];
System.out.println("Enter ten numbers: ");
for (int i = 0; i < numbers.length; i++) {
numbers[i] = keyBoard.nextInt();
}
System.out.println("Here is the list of Even number/s:");
for (int i = 0; i < numbers.length; i++) {
if (numbers[i] % 2 == 0) {
System.out.print(numbers[i] + " ");
}
}
keyBoard.close();
}
}
Comments
Leave a comment