Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a method writeSequence that accepts an integer n as a parameter and pri

ID: 3676310 • Letter: 1

Question

1. Write a method writeSequence that accepts an integer n as a parameter and prints a symmetric sequence of n numbers with descending integers ending in 1 followed by ascending integers beginning with 1, as in the table below:

Call Output

writeSequence(1); 1

writeSequence(2); 1 1

writeSequence(3); 2 1 2

writeSequence(4); 2 1 1 2

writeSequence(5); 3 2 1 2 3

writeSequence(6); 3 2 1 1 2 3

writeSequence(7); 4 3 2 1 2 3 4

writeSequence(8); 4 3 2 1 1 2 3 4

writeSequence(9); 5 4 3 2 1 2 3 4 5

writeSequence(10); 5 4 3 2 1 1 2 3 4 5

Notice that for odd numbers the sequence has a single 1 in the middle while for even values it has two 1s in the middle. A client using this method would have to call println to print the line of output

. 2. Write the complete Board.java class and the complete solveQueens.java class that will solve the “8 Queens” problem described in the slides provided in BrightSpace. The slides provide partial solution to the problem.

Your program should print the solution in the following format. One solution is as follows:

Q - - - - - - -

- - - - - - Q -

- - - - Q - - -

- - - - - - - Q

- Q - - - - - -

- - - Q - - - -

- - - - - Q - -

- - Q - - - - -

Explanation / Answer

Please find the required codes below :

1)

2) Not given what is there in the slides. Not attached anything mentioned related to slides provided in BrightSpace.