I cant figure out how to check the array for AND and OR. please, help, i got stuck

my code:

import java.util.Scanner;

public class BooleanProduct

import java.util.Scanner;

public class BooleanProduct
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int[][] A = new int[10][10];
int[][] B = new int[10][10];
int[][] C = new int[10][10];
int m,n,p,q;
System.out.println("Enter number of rows for matrix A : ");
m = input.nextInt();
System.out.println("Enter number of columns for matrix A : ");
n = input.nextInt();
System.out.println("Enter number of rows for matrix B : ");
p = input.nextInt();
System.out.println("Enter number of columns for matrix B : ");
q = input.nextInt();
System.out.println("Enter elements for matrix A (by rows): ");
for (int i=0 ; i < m ; i++)
for(int j=0 ; j < n ; j++)
{
A[i][j] = input.nextInt();
}
System.out.println("Enter elements for matrix B : ");
for (int i=0 ; i < p ; i++)
for(int j=0 ; j < q ; j++){
B[i][j] = input.nextInt();
}
System.out.println("Matrix A: ");
for(int i=0 ; i < m ; i++)
{
System.out.println();
for(int j=0 ; j < n ; j++)
{
System.out.print(A[i][j]+" ");
}
}
System.out.println();
System.out.println("Matrix B: ");
for (int i=0 ; i < p ; i++)
{ System.out.println();
for(int j=0 ; j < q ; j++){
System.out.print(B[i][j]+" ");
}
}
System.out.println();
}
}
System.out.println("Boolean Product of matrices A and B is: ");
{
 i=0;
 j=0;
  if (A [i][j]==1 && B [i][j]==1)
 {
     temp C [i][j] = 1;
     i++;
     j++;
 }
 else
 {
     C [i][j]= 0;
     i++;
     j++;
 }
}
{

.... i lost it here...how can i store the value, because i need it than to compare it with OR ||

Recommended Answers

All 3 Replies

tried
if (A [i][j]==1 || B [i][j]==1)
?

well, but first i gotta do AND operator &&. After that two value compare with OR ||. I gor new values after &&. do i store them and how? and than use OR operator on them?

You can use parens to control the order of execution, eg

((a && b) || (c && d))
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.