Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am trying to make an applet in java that enables me to be able toprint the arr

ID: 3614981 • Letter: I

Question

I am trying to make an applet in java that enables me to be able toprint the array I made. The goal is to make all of the '#'characters from the array to turn into 10x10 Blue squares, and the' ' characters into just a default 10x10 white square. I reallyneed help on this one, I am stuck.

Here is the code... It's pretty bad, but I just don't know what todo at this point anymore. :(

import javax.swing.JApplet;
import java.awt.*;

public class Lab8b extends JApplet{
  
    public void paint(Graphics g){
  
    // Declare char array
    char shape[] = new char[150];
  
    // Let's set up our 10x15 block filled with '#'characters
    for (int i = 0; i < shape.length; i++){
   
      shape[i] = '#';
       
    }
    // Create a space for every space in the arrayto make a "B"
        shape[11] = ' ';
        shape[12] = ' ';
        shape[13] = ' ';
        shape[14] = ' ';
        shape[15] = ' ';
        shape[16] = ' ';
        shape[21] = ' ';
        shape[27] = ' ';
        shape[31] = ' ';
        shape[38] = ' ';
        shape[41] = ' ';
        shape[48] = ' ';
        shape[51] = ' ';
        shape[58] = ' ';
        shape[61] = ' ';
        shape[67] = ' ';
        shape[71] = ' ';
        shape[72] = ' ';
        shape[73] = ' ';
        shape[74] = ' ';
        shape[75] = ' ';
        shape[76] = ' ';
        shape[81] = ' ';
        shape[87] = ' ';
        shape[91] = ' ';
        shape[98] = ' ';
        shape[101] = ' ';
        shape[108] = ' ';
        shape[111] = ' ';
        shape[118] = ' ';
        shape[121] = ' ';
        shape[127] = ' ';
        shape[131] = ' ';
        shape[132] = ' ';
        shape[133] = ' ';
        shape[134] = ' ';
        shape[135] = ' ';
        shape[136] = ' ';
       
        g.setColor(Color.white);
        g.fillRect(0,0,10,10);
       
        for (int x = 0; x <= 90; x= x + 10){
        for (int y = 0; y <= 140;y = y + 10){
           g.setColor(Color.blue);
           g.fillRect(x, y, 10, 10);
           
        } // end for
        } // end for

} // end paint
} // end class

Explanation / Answer

hope this sets you in the right direction the problem with your code is 2 fold. you create the 2 dimensional array as 1 dimensional and the try toprint it 2 dimensional, create it 2 dimensional it's a 10*10 matrix but the you use 150 values which makes me think10*15 after you do that message me and I'll take another look after you change the code to create the letter b as 2dimensional then when you loop to output for(x=0;x
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote