Question: Help please! Why am I getting an ArrayIndexOutOfBoundsException here? import java.util.Scanner; public class ASCIIFigureRotation { public static void main(String[] args) { Scanner scan = new

Help please!

Why am I getting an ArrayIndexOutOfBoundsException here?

Help please! Why am I getting an ArrayIndexOutOfBoundsException here? import java.util.Scanner; public

class ASCIIFigureRotation { public static void main(String[] args) { Scanner scan =

import java.util.Scanner; public class ASCIIFigureRotation { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); while (n != 0) { // Read the characters of the figure char[][] figure = new char[n][100]; for (int i = 0; i = 0; i--) { if (figure[i][j] != ' ') { m = j; break; } } } char[][] rotatedFigure = new char[m + 1][n]; for (int i = 0; i   Consider an ASCII art figure like the one on the left. If the figure contains only spaces and the +, and  symbols, then its possible to produce rotated versions of the figure using ASCII art. For example, the figure on the right is a 90 degree clockwise rotation of the one on the left (note that - and | are swapped in the rotation). Your job is to develop a program that rotates ASCII art figures like this automatically. Input Input consists of up to 100 figures. Each figure starts with an integer 1n100. Following this are n lines of up to 100 characters each, containing only spaces, +, -, and |. Each line ends in a non-space character. Each image has at least one non-space character somewhere in its leftmost column. Input ends with a line containing only the number 0 . Output For each figure, print a copy of the figure rotated 90 degrees clockwise. Like the input, your output should contain no spaces after the last non-space character of a line, and adjacent figures should be separated by a single blank line. Sample Input 1 Sample Output 1

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!