Write a java program using two-dimensional arrays that determines the ODD numbers among the 12 input values typed from the keyboard and prints the list of these ODD numbers.
import java.util.Scanner;
public class Answer {
public static void main(String[] args) {
int[][] array = new int[12] [1];
System.out.println("Enter numbers:");
Scanner scanner =new Scanner(System.in);
for (int i = 0; i < array.length; i++) {
array[i][0] = scanner.nextInt();
}
System.out.print("ODD numbers: ");
for (int i = 0; i < array.length; i++) {
if (array[i][0] % 2 != 0) {
System.out.print(array[i][0] + " ");
}
}
}
}
Comments
Leave a comment