## NearbyBridge's Profile User Rating:

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
8 (0.01 per day)
Joined:
25-November 12
Profile Views:
276
Last Active:
Dec 04 2012 05:52 PM
Currently:
Offline

### Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
AMD
Favorite Gaming Platform:
Playstation
Chevrolet
Dream Kudos:
0
NearbyBridge has not set their status

1. #### In Topic: Test if a n x n matrix is a positive Markov matrix

Posted 25 Nov 2012

Thats line 15 on my netbeans is why I ask

I don't know much about errors but i was assuming the "15" in the "MarkovMatrix.main(MarkovMatrix.java:15)" was referring to the line number.
2. #### In Topic: Test if a n x n matrix is a positive Markov matrix

Posted 25 Nov 2012

Hahaha that was silly of me. I change what you said however I am still receiving one error.

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
at MarkovMatrix.main(MarkovMatrix.java:15)
Java Result: 1

```public class MarkovMatrix {

public static void main(String args[]) {
double[][] matrix = new double[3][3];
Scanner input = new Scanner(System.in);
System.out.println("Enter a 3-by-3 matrix row by row");
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; i++) {
matrix[i][j] = input.nextDouble();
}
}
}

public static boolean isMarkovMatrix(double[][] m) {

for (int j = 0; j < m.length; j++){
double sum = 0;
for (int i = 0; i < m.length; i++) {
if (m[i][j] < 0) {
return false;
}
sum += m[i][j];
}

if (sum != 1) {
return false;
}

}

return true;

}
}
```

is it something to do with this line

```for (int j = 0; j < matrix[i].length; i++) {
```
3. #### In Topic: Test if a n x n matrix is a positive Markov matrix

Posted 25 Nov 2012

Okay, this is what I have now I started writing this before I read your comment. But let me know what you think about it. It is still incorrect. This is the error I receive

at java.util.Scanner.throwFor(Scanner.java:840)
at java.util.Scanner.next(Scanner.java:1461)
at java.util.Scanner.nextInt(Scanner.java:2091)
at java.util.Scanner.nextInt(Scanner.java:2050)
at MarkovMatrix.main(MarkovMatrix.java:16)
Java Result: 1

```import java.util.*;

public class MarkovMatrix {

public static void main(String args[]) {
int[][] matrix = new int[3][3];
Scanner input = new Scanner(System.in);
System.out.println("Enter a 3-by-3 matrix row by row");
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; i++) {
matrix[i][j] = input.nextInt();
}
}
}

public static boolean isMarkovMatrix(double[][] m) {

for (int j = 0; j < m.length; j++){
double sum = 0;
for (int i = 0; i < m.length; i++) {
if (m[i][j] < 0) {
return false;
}
sum += m[i][j];
}

if (sum != 1) {
return false;
}

}

return true;

}
}
```
4. #### In Topic: Program that displays whether two lists of integers identical or not

Posted 25 Nov 2012

I was trying to make it return false if the lengths of the two arrays were not equal
5. #### In Topic: Program that displays whether two lists of integers identical or not

Posted 25 Nov 2012

I changed it a little bit and I think this is a little better but it's still not quite right because it returns identical for:

51 5 22 6 1 4 24 54 6
51 22 25 6 1 4 24 54 6

but it should return identical

```import java.util.Scanner ;

public class Exercise07_29 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);

final int row = 3;
final int column = 3;
System.out.print("Enter list1: ");
int[][] m1 = new int[row][column];
for (int i = 0; i < m1.length; i++)
for (int j = 0; j < m1[0].length; j++)
m1[i][j] = input.nextInt();

System.out.print("Enter list2: ");
int[][] m2 = new int[row][column];
for (int i = 0; i < m2.length; i++)
for (int j = 0; j < m2[0].length; j++)
m2[i][j] = input.nextInt();

if (equals(m1, m2))
System.out.println("The two arrays are identical");
else
System.out.println("The two arrays are not identical");
}

public static boolean equals(int[][] m1, int[][] m2) {
if (m1.length * m1[0].length != m2.length * m2[0].length)
return false;

for (int i = 0; i < m1.length; i++)
for (int j = 0; j < m1[0].length; j++)
if (m1[i][j] != m2[i][j])
return true;

return true;
}
}

```

WOW that is so much since!. I feel like a clutz. Thank you so much.

### My Information

Member Title:
Age:
24 years old
Birthday:
June 12, 1990
Gender:
Location:
Savannah, GA
Interests:
Video Games, Programming, Computers, Guitars, Music, Animals
Full Name:
Joshua Evan Queen
Years Programming:
1
Programming Languages:
Java

### Contact Information

E-mail:
Private
MSN:
jq9377@stu.armstrong.edu