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, 22.06.2019 14:30
Create a pseudocode design to prompt a student for their student id and the titles of the three classes they want to add. the solution should display the student’s id and a total bill. • bill a student using the following rules: o students can only add up to 3 classes at a time.
Answers: 3
question
Computers and Technology, 23.06.2019 12:10
2. fabulously fit offers memberships for$35 per month plus a $50 enrollmentfee. the fitness studio offersmemberships for $40 per month plus a$35 enrollment fee. in how many monthswill the fitness clubs cost the same? what will the cost be?
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
Best laptops for college [$100-$500 range]?
Answers: 2
question
Computers and Technology, 23.06.2019 17:30
What are the most commonly found items in the trash according to the municipal solid waste report?
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
Computers and Technology, 17.12.2019 22:31
question
Mathematics, 17.12.2019 22:31
question
Mathematics, 17.12.2019 22:31
question
Chemistry, 17.12.2019 22:31