Consider an image that is composed of a number of colored small squares, each colored in one of these 8 colors: red, green, blue, cyan, magenta, yellow, black, white. The colors are stored in a String using the first letter of each color (R, G, B, C, M, Y, K, W). Each row in the image is terminated by a newline character ('\n'). Here is an example of an image:

String imageCode = "RRR\nRGR\nRRR\n";

This is a green square surrounded by red squares.

Your task is to write a method that doubles the image in size, making each square twice as large in each direction. For example, when calling doubleImage with imageCode, the returned image is

"RRRRRR\nRRRRRR\nRRGGRR\nRRGGRR\nRRRRRR\nRRRRRR\n"

Complete the following file:

ColorCodes.java

public class ColorCodes { /** Returns the code of the given image when doubled in size @param img the codes of an image @return the color codes of the doubled image */ public String doubleImage(String img) { String result = ""; for (int i = 0; i < img.length(); i++) { char ch = img.charAt(i); if (ch == '\n') { // your work here } else { // your work here } } return result; } }