subject

Write a program ThueMorse. java that takes an integer command-line argument n and prints an n-by-n pattern like the ones below. Include two space characters between each + and - character.
Have to use array and cannot call string method charAt.
Hint provided was to use boolean array of length n.
This is my current code:
public class ThueMorse {
public static void main(String[] args) {
int n = Integer. parseInt(args[0]);
String[] tm = {"0", "1"};
tm[0] = "0";
tm[1] = "1";
for (int k = 1; k <= n; k++) {
String t = tm[0];
String m = tm[1];
tm[0] += m;
tm[1] += t;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (tm[0].charAt(i) == tm[0].charAt(j))
System. out. print("+ ");
else
System. out. print("- ");
}
System. out. println();
}
}
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 18:00
Is the following sentence true or false? during meiosis, the two alleles for each gene stay together.
Answers: 3
question
Computers and Technology, 22.06.2019 17:00
Aisha has finished working on a word processing document that contains 15 pages. she has added some special elements in the first three pages, page 9 and 10, and page 15 from the document. she wants to print only these pages to see how they look. which option is the correct way to represent (in the print dialog box) the pages that aisha wants to print
Answers: 3
question
Computers and Technology, 22.06.2019 22:30
The qwerty keyboard is the most common layout of keys on a keyboard
Answers: 3
question
Computers and Technology, 23.06.2019 02:00
In the context of an internet connection, llc stands for leased line connection liability limited company local loop complex local loop carrier
Answers: 1
You know the right answer?
Write a program ThueMorse. java that takes an integer command-line argument n and prints an n-by-n...
Questions
question
Mathematics, 20.09.2020 05:01
question
Mathematics, 20.09.2020 05:01
question
Arts, 20.09.2020 05:01
question
Mathematics, 20.09.2020 05:01
Questions on the website: 13722361