Computer Science, asked by modi2143, 4 months ago

part 1 add 2 assignment statements for the 2d array ascii art to change the o characters to @ characters. part 2 create a new ascii art array and print it out reddjt

Answers

Answered by bg11022002
0

Answer:

public class AsciiArt

{

  public static void main(String[] args)

  {

     String[][] asciiArt = {

           {" ", " ", "_", "_", "_", " ", " "},

           {" ", "(", "o", " ", "o", ")", " "},

           {"(", " ", " ", "V", " ", " ", ")"},

           {" ", "-", "m", "-", "m", "-", " "},

      };

     //Part 1: Add 2 assignment statements to change "o" to "@"

     asciiArt [1][2] = "@";

     asciiArt [1][4] = "@";

     // print the asciiArt for Part 1

     System.out.println("ASCII Art:");

     for(String[] row : asciiArt) {

       for(String column : row)

         System.out.print(column);

       System.out.println();

     }

     //Part 2: Create your own ASCII art array and print it out!

      String[][] MyasciiArt = {

           {"b", ".", "", "", "", ""},

           {"8", "8", "b", "", "", ""},

           {"8", "8", "8", "b", ".", ""},

           {"8", "8", "8", "8", "P", ""},

           {"P", " ", " ", "8", ".", ""},

           {" ", " ", " ", " ", "8", ""},

      };

      System.out.println("My ASCII Art:");

     for(String[] row : MyasciiArt) {

       for(String column : row)

         System.out.print(column);

       System.out.println();

     }

  }

}

Explanation:

Reassign these things and you get the first part done

//Part 1: Add 2 assignment statements to change "o" to "@"

     asciiArt [1][2] = "@";

     asciiArt [1][4] = "@";

Make your own art! You can do whatever you want, here is mine or something! Anyways make sure to print it out as well

     //Part 2: Create your own ASCII art array and print it out!

      String[][] MyasciiArt = {

           {"b", ".", "", "", "", ""},

           {"8", "8", "b", "", "", ""},

           {"8", "8", "8", "b", ".", ""},

           {"8", "8", "8", "8", "P", ""},

           {"P", " ", " ", "8", ".", ""},

           {" ", " ", " ", " ", "8", ""},

      };

      System.out.println("My ASCII Art:");

     for(String[] row : MyasciiArt) {

       for(String column : row)

         System.out.print(column);

       System.out.println();

     }

Answered by HrishikeshSangha
0

Part 1:

To change the "o" characters to "@" characters in a 2D array, you can use nested loops to iterate over each row and column, and then use an if statement to check if the current element is "o". If it is, you can assign "@" to that element using the assignment operator.

Here's an example of how you could do it:

# Original 2D array with "o" characters

ascii_art = [

   ["o", "o", "o", " "],

   ["o", " ", "o", " "],

   ["o", "o", "o", " "],

   [" ", " ", " ", " "]

]

# Replace "o" with "@"

for row in range(len(ascii_art)):

   for col in range(len(ascii_art[row])):

       if ascii_art[row][col] == "o":

           ascii_art[row][col] = "@"

# Print out the modified 2D array

for row in ascii_art:

   print("".join(row))

Output:

@@@

@ @

@@@

   

Part 2:

To create a new ASCII art array, you can simply assign a new 2D array to a variable. Here's an example:

# New ASCII art array

new_ascii_art = [

   ["\\", "/", "/", "\\"],

   ["/", " ", " ", "\\"],

   ["\\", " ", " ", "/"],

   ["/", "\\", "\\", "/"]

]

# Print out the new ASCII art array

for row in new_ascii_art:

   print("".join(row))

Output:

\/\\

/  \

\  /

/\\/\

For more reference visit,

https://brainly.in/question/50357362?referrer=searchResults

https://brainly.in/question/37691719?referrer=searchResults

#SPJ3

Similar questions