Question: need help with what is wrong with my code? import java.io.File; import java.io.FileNotFoundException; // Import this class to handle errors import java.util.Scanner; class Relation {

need help with what is wrong with my code?

import java.io.File;

import java.io.FileNotFoundException; // Import this class to handle errors

import java.util.Scanner;

class Relation {

// This method returns if matrixrix is reflexive or not

public static Boolean isReflexive(int matrix[][],int n){

for(int i=0;i

if(matrix[i][i]!=1)

return false;

}

return true;

}

// This method returns if matrixrix is antireflexive or not

public static Boolean isAntiReflexive(int matrix[][],int n){

for(int i=0;i

if(matrix[i][i]!=0)

return false;

}

return true;

}

// This method returns if matrixrix is symmetric or not

public static Boolean isSymmetric(int matrix[][],int n){

for(int i=0;i

for(int j=0;j

if(i==j)

continue;

if(matrix[i][j]!=matrix[j][i])

return false;

}

}

return true;

}

// This method returns if matrixrix is antisymmetric or not

public static Boolean isAntiSymmetric(int matrix[][],int n){

for(int i=0;i

for(int j=0;j

if(i==j)

continue;

if(matrix[i][j]==matrix[j][i])

return false;

}

}

return true;

}

public static void main(String[] args) {

// Reading file name from user

System.out.print("File input: ");

Scanner sc = new Scanner(System.in);

String file_name = sc.nextLine();

sc.close();

// try to open and read file

try {

File myObj = new File(file_name);

Scanner user = new Scanner(myObj);

int matrix[][] = new int[10][10];

int i=0;

// reading the file and filling matrix

while (user.hasNextLine()) {

String data = user.nextLine();

for(int j=0;j

matrix[i][j] = Integer.parseInt(data.split(" ")[j]);

}

i++;

}

// Displaying all the output

System.out.println("Reflexive - " + (isReflexive(matrix, 10) ? "yes" : "no"));

System.out.println("AntiReflexive - " + (isAntiReflexive(matrix, 10) ? "yes" : "no"));

System.out.println("Symmetric - " + (isSymmetric(matrix, 10) ? "yes" : "no"));

System.out.println("Antisymmetric - " + (isAntiSymmetric(matrix, 10) ? "yes" : "no"));

user.close();

} catch (FileNotFoundException e) { // if error occurred while opening the file

System.out.println("An error occurred.");

e.printStackTrace();

}

}

}need help with what is wrong with my code? import java.io.File; importjava.io.FileNotFoundException; // Import this class to handle errors import java.util.Scanner; class Relation

Output Your program should output statements that claim the existence or violation of each property. A sample program output is given below. File input: matrix5.txt Reflexive - yes Antireflexive Symmetric - yes Antisymmetric yes no Test cases Matrix1.txt 1 1 1 0 1 0 0 1 1 o o o 1 1 1 1 1 oo 1 1 1 1 POOP Matrix2.txt oo 1 1 0 1 0 1 1 1 0 1 0 0 0 1 0 1 0 1 0 0 1 1 0 1 0 oo 1 o 1 1 0 1 0 1 0 0 1 1 0 1 1 0 1 0 1 1 o 1 1 1 1 1 1 1 0 0 1 0 1001001001 RO Matrix3.txt Search documents and file 0 1 1 1 1 0 1 0 1 1 0 1 1 0 0 1 1 o o o 1 oo 1 1 1 0 0 0 oo 1 o 1 o 1 0 1 1 1 1 1 1 1 1 0 1 1 1 0 0 1 oo 1 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!