Question: help with this Java problem. Thanks! Assume pixels? is a 3x3 2D floating point array double[3][3]?. What is the output of the following code: public

help with this Java problem. Thanks!

Assume pixels? is a 3x3 2D floating point array double[3][3]?. What is the output of the following code:

public static void main(void){

fill(3.7);

print(true);

fill(8.9);

print(false);

fill(2);

print(true);

}

public void print(boolean raw) {

for (int i = 0; i < sizeX; i++) {

for (int j = 0; j < sizeY; j++) {

if (raw == true)

{ System.out.print(getPixel(i, j, 0) + " ");

} else { System.out.print((int) (getPixel(i, j, 0)) + " ");

}

}

System.out.println(); }

System.out.println(" "); }

public void fill(double value) {

for (int i = 0; i < sizeX; i++) {

for (int j = 0; j < sizeY; j++) {

pixels[i][j] = value; }

}

} public double getPixel(int x, int y, double pad) {

if (x >= sizeX || x < 0 || y < 0 || y >= sizeY) {

return pad;

}

return pixels[x][y];

}

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!