Given two 2x3 (2 rows, 3 columns) arrays of integer , x1 and x2, both already initialized , two integer variables , i and j, and a boolean variable x1rules. write the code that is necessary for x1rules to be true if and only if every element in x1 is bigger than its corresponding element in x2 and is false otherwise

Respuesta :

JAVA programming was employed...

What we have so far:
* Two 2x3 (2 rows and 3 columns) arrays. x1[i][j] (first 2x3 array) and x2[i][j] (second 2x3 array) .
* Let i = row and j = coulumn.
* A boolean vaiable, x1rules

Solution:

for(int i=0; i<2; i++)
{
   for(int j=0; j<3; j++)
   {
      x1[i][j] = num.nextInt();
   }
}// End of Array 1, x1.

for(int i=0; i<2; i++)
{
   for(int j=0; j<3; j++)
   {
      x2[i][j] = num.nextInt();
   }
}//End of Array 2, x2
This should check if all the elements in x1 is greater than x2:

x1rules = false;
if(x1[0][0]>x2[0][0] && x1[0][1]>x2[0][1] && x1[0][2]>x2[0][2] && x1[1][0]>x2[1][0] && x1[1][1]>x2[1][1] && x1[1][2]>x2[1][2])
{
   x1rules = true;
   system.out.print(x1rules);
}
else
{
   system.out.print(x1rules);
}//Conditional Statement