8A

E6.11

Use the prompt "Enter a word"

For the draft, just print the substrings of length 1.

A draft: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=13011520438123390447413786299
A final: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=13011520438123390447413786299&level=2

8B

For this problem, you are going to create a class PatchworkQuilt which has a constructor and a draw method. Our quilt will have solid squares.

The constructor takes three parameters: the upper left x and the top y coordinates of the starting location of the quilt and the width of a square .All PatchWorkQuilts are 8 squares wide by 8 squares high. The colors of the squares alternate. The first row is black, yellow, red, blue and then repeats. The second row is yellow, red, blue and then repeats. And so on. Look at the screen shot. You must use nested loops. Provide a draw method that takes a Graphics2D object as argument

For the draft, provide the constructor and a draw method that draws a single black square at the x, y coordinates.

patchwork quilt

8B draft: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=13011520482575500460229866927
8B final: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=13011520482575500460229866927&level=2

8C

Complete the ArraysMethods class. All the methods have been implemented as stubs so the class compiles

public class ArrayMethods
{
    private int[] values;

    public ArrayMethods(int[] initialValues)
    {
        values = initialValues;
    }

    public void swapFirstAndLast()
    {

    }

    public void shiftRight()
    {

    }

    public void removeMiddle()
    {

    }

    public int secondLargest()
    {
        return 0;
    }

    public boolean isSorted()
    {
        return false;
    }
}
  1. Swap the first and last elements in the array.
  2. Shift all elements by one to the right and move the last element into the first position. For example, 1 4 9 16 25 would be transformed into 25 1 4 9 16.
  3. Remove the middle element of an ordered array if the array length is odd, or the middle two elements if the length is even. Set the last element(s) in the array to 0 after moving them
  4. Return the second-largest element in the array.
  5. Return true if the array is currently sorted in increasing order.

For the draft, implement a and b

8C draft: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=13011822008754237684797324945
8C final: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=13011822008754237684797324945&level=2