public class MPGH
{
public static void main (String args[])
{
int control = 1;
int[] myArray = new int[15];
for (int index = 0; index < myArray.length; index++)
{
int r = (int)(Math.random() *10);
myArray[index]= r;
System.out.print(myArray[index] + " ");
}
for (int index = 0; index < myArray.length; index++)
{
if (control == 1)
{
myArray[index] = myArray[index] - myArray[index] * 2;
control--;
}
else
{
control++;
}
}
System.out.println("\n");
for (int index = 0; index < myArray.length; index++)
{
System.out.print(myArray[index] + " ");
}
} //end main
} //end class Main
import javax.swing.JOptionPane;
public class MPGH
{
public static void main (String args[])
{
int control = 1;
int[][] myArray = new int[15][2];
for (int index = 0; index < 15; index++)
{
String numChoice = JOptionPane.showInputDialog( "Please enter a number!");
int r = Integer.parseInt( numChoice );
myArray[index][0]= r;
System.out.print(myArray[index][0] + " "); //prints out [1 , 0], [2 , 0], ... [15, 0]
}
for (int index = 0; index < 15; index++)
{
if (control == 1)
{
myArray[index][1] = myArray[index][0] - myArray[index][0]* 2;
control--;
}
else
{
myArray[index][1] = myArray[index][0];
control++;
}
}
System.out.println("\n");
for (int index = 0; index < 15; index++)
{
System.out.print(myArray[index][1] + " "); //prints out [1 , 1], [2 , 1], ... [15, 1]
}
} //end main
} //end class Main
for (int i = 0; i < array.length; i++) {
if (array[i]%2 == 0) {
System.out.print(array[i] + " is " + "even, ");
} else {
System.out.print(array[i] + " is " + "odd, ");
}
}