Device Info:
Pipo N7
Android 7.0
rooted with stock ROM
(I think I have Premium Key)
I compiled a program using Java console and the program only works correctly when I make a break point and run it that way.
here is the program and the output
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
double[][] ma = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9}
};
double[][] mb = {
{0, 2, 4},
{1, 4.5, 2.2},
{1.1, 4.3, 5.2}
};
double[][] mc;
mc = multiplyMatrix(ma, mb);
double d;
for(int i = 0; i < mc.length; i++){
for(int j = 0; j < mc[0].length; j++){
d = mc[i][j];
System.out.println(d);
}
System.out.println();
}
}
public static double[][] multiplyMatrix(double[][] a, double[][] b){
if(a.length != b[0].length || b.length != a[0].length){
System.out.println("Incorect input the metriices nned tp ba squared");
return null;
}
double[][] c = new double[a.length][a[0].length];
for(int i = 0; i < a.length; i++){
for(int j = 0; j < a[0].length; j++){
c[i][j] = a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j];
//cij = ai1 * b1j + ai2 * b2j + ai3 * b3j
}
}
return c;
}
}
** Output **
5.300000000000001
17.5
24.0
11.600000000000001
37.0
58.2
17.9
56.5
92.4
** End Output **
The expected output should be
5.300000000000001
23.9
24.0
11.600000000000001
56.3
58.2
17.9
88.69999999999999
92.4
The middle number of each set is incorrect I can only get it to work when I put a breakpoint into the program.
Thank You for your help.
Israel