SOLUTION:
Copy the given code into NetBeans where the project folder's main class is present.
import java.util.*;
public class MyClass {
public static void main(String args[]) {
//Svanner is used to read data from User
Scanner sc = new Scanner(System.in);
//2d array Declaration
int[][] num = new int[2][10];
//Variable Declarations
int i=0;
int j=0;
int k=0;
// loop to read and store user data into loop
while(i<20){
num[j][k]=sc.nextInt();
k+=1;
if(i==9){
j+=1;
k=0;
}
i++;
}
// Head of the Table
System.out.println("-----------------------------------------------");
System.out.printf("%10s %10s %10s %10s", "Index", "Value", "Even", "Odd");
System.out.println();
System.out.println("-----------------------------------------------");
k=0;
// Rows of the Table
for(i=0;i<2;i++){
for(j=0;j<10;j++){
int val=num[i][j];
System.out.format("%10s %10s %10s %10s",
k++,val,val%2==0,val%2!=0);
System.out.println();
}
}
System.out.println("-----------------------------------------------");
}
}
OUTPUT:
Get Answers For Free
Most questions answered within 1 hours.