Question: How do I print the 2d array in a table format and a 1d array besides that table? In the code below I'm printing everything

How do I print the 2d array in a table format and a 1d array besides that table?

In the code below I'm printing everything but it not very readable. The code it just a snippet of my program.

System.out.print("Speed");

for(int i=0; i

// printing on top of the table

System.out.print( angelsArray[i] + " deg ");

}

for(int row =0; row

for(int col =0; col

// need to be printed in the right side of the table

System.out.printf("%-2d",speedsArray[col]);

// print as a table

trajectoryValues = catapult.trajectoriesCalculations(speedsArray, angelsArray);

System.out.println();

System.out.printf("%15f", trajectoryValues[row][col]);

}

}

// The current output

Speed10 deg 15 deg 20 deg 25 deg 30 deg 35 deg 40 deg 45 deg 10 3.00000015 5.00000020 6.00000025 7.00000030 8.00000035 9.00000040 10.00000045 10.00000010 7.00000015 11.00000020 14.00000025 17.00000030 19.00000035 21.00000040 22.00000045 22.00000010 13.00000015 20.00000020 26.00000025 31.00000030 35.00000035 38.00000040 40.00000045 40.00000010 21.00000015 31.00000020 40.00000025 48.00000030 55.00000035 59.00000040 62.00000045 63.00000010 31.00000015 45.00000020 59.00000025 70.00000030 79.00000035 86.00000040 90.00000045 91.00000010 42.00000015 62.00000020 80.00000025 95.00000030 108.00000035 117.00000040 123.00000045 124.00000010 55.00000015 81.00000020 104.00000025 125.00000030 141.00000035 153.00000040 160.00000045 163.00000010 70.00000015 103.00000020 132.00000025 158.00000030 178.00000035 194.00000040 203.00000045 206.000000

// desired output

How do I print the 2d array in a table format and

Projectile le Speed 10 15 20 25 30 35 40 45 10 deg 1.063 2.392 4.252 6.644 9.567 13.022 17.009 21.527 15 deg 1.554 3.497 6.216 9.713 13.987 19.037 24.865 31.470 20 deg 1.998 4.495 7.991 12.487 17.981 24.474 31.966 40.457 25 deg 2.381 5.357 9.524 14.881 21.429 29.167 38.095 48.215 30 deg 2.692 6.056 10.767 16.823 24.225 32.974 43.067 54.507 35 deg 2.921 6.572 11.683 18.254 26.286 35.778 46.731 59.144 40 deg 3.061 6.887 12.244 19.131 27.548 37.496 48.975 61.983

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!