#IDK where it the problem

1 messages ยท Page 1 of 1 (latest)

ionic jungleBOT
#

<@&987246399047479336> please have a look, thanks.

errant gorge
#

my code

#

import java.math.BigDecimal;

import static Ez.Print.print2D;
import java.math.BigDecimal;

public class q14 {
public static void main(String[] args) {
int size = 5;
BigDecimal[][] mat = new BigDecimal[size][size];
for (int x = 0; x < size; x++)
{
for (int y = 0; y < size; y++)
{
mat[x][y] = BigDecimal.valueOf(Math.pow(Math.PI, x))
.divide(BigDecimal.valueOf(y + 1), 10, BigDecimal.ROUND_HALF_UP);

        }

    }
    print2D (mat);
}

}

ionic jungleBOT
#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
Typing

It seems like you are having trouble identifying an issue in your Java code. To pinpoint the problem, try debugging your code line by line or using a debugger tool like IntelliJ or Eclipse. You can also print out intermediate values to track the flow of your program.

Useful links:

errant gorge
#

my package

#

package Ez;

import java.math.BigDecimal;

public class Print {

// ----------- BigDecimal Matrix -----------
public static void print2D(BigDecimal[][] mat) {
    if (mat == null || mat.length == 0) {
        System.out.println("(empty)");
        return;
    }

    int cols = mat[0].length;
    int[] colWidths = new int[cols];

    // Calculate max width per column
    for (BigDecimal[] row : mat) {
        for (int j = 0; j < cols; j++) {
            String val = (row[j] != null) ? row[j].toPlainString() : "null";
            colWidths[j] = Math.max(colWidths[j], val.length());
        }
    }

    // Print with alignment
    for (BigDecimal[] row : mat) {
        for (int j = 0; j < cols; j++) {
            String val = (row[j] != null) ? row[j].toPlainString() : "null";
            System.out.printf("%" + colWidths[j] + "s ", val);
        }
        System.out.println();
    }
}

// ----------- long Matrix -----------
public static void print2D(long[][] mat) {
    if (mat == null || mat.length == 0) {
        System.out.println("(empty)");
        return;
    }

    int cols = mat[0].length;
    int[] colWidths = new int[cols];

    for (long[] row : mat) {
        for (int j = 0; j < cols; j++) {
            colWidths[j] = Math.max(colWidths[j], String.valueOf(row[j]).length());
        }
    }

    for (long[] row : mat) {
        for (int j = 0; j < cols; j++) {
            System.out.printf("%" + colWidths[j] + "d ", row[j]);
        }
        System.out.println();
    }
}

}

#

why the outpug is
"C:\Program Files\Java\jdk-21\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2025.2.2\lib\idea_rt.jar=63642" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath C:\Users\maste\Downloads\imp-2\Code\Test\out\production\Test Speed
153342962

Process finished with exit code 0

#

i fount i was running another file sorry