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 02:30
If you turn on the lock alpha button , what happens
Answers: 1
question
Computers and Technology, 23.06.2019 07:00
Why is investing in a mutual fund less risky than investing in a particular company's stock? a. mutual funds only invest in blue-chip stocks. b. investments in mutual funds are more liquid. c. mutual funds hold a diversified portfolio of stocks. d. investments in mutual funds offer a higher rate of return.
Answers: 2
question
Computers and Technology, 23.06.2019 07:00
1. you have a small business that is divided into 3 departments: accounting, sales, and administration. these departments have the following number of devices (computers, printers, etc.): accounting-31, sales-28, and administration-13. using a class c private network, subnet the network so that each department will have their own subnet. you must show/explain how you arrived at your conclusion and also show the following: all available device addresses for each department, the broadcast address for each department, and the network address for each department. also, determine how many "wasted" (not usable) addresses resulted from your subnetting (enumerate them).
Answers: 3
question
Computers and Technology, 23.06.2019 08:00
Michael has written an e-mail to his employees that describes a new product special that will be introduced to the customers next week. by taking time to make sure the e-mail is well written, logical, and organized, michael has made sure his message has the characteristics of a) effective communicationb) ineffective communicationc) barriers to communicationd) workplace communication
Answers: 2
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, 11.03.2021 22:40
question
Social Studies, 11.03.2021 22:40
question
Mathematics, 11.03.2021 22:40
question
Social Studies, 11.03.2021 22:40
Questions on the website: 13722363