Home /
Expert Answers /
Computer Science /
x1012-nested-for-loops-for-pixel-coordinates-for-this-question-you-will-be-working-with-a-picture-pa472
(Solved):
X1012: Nested For Loops for Pixel Coordinates For this question you will be working with a Picture ...
X1012: Nested For Loops for Pixel Coordinates For this question you will be working with a Picture object, but you may not call getPixels() for your loop. Instead, you will need to use a pair of nested for loops to loop over all \( (x, y) \) coordinates. Finish the inner for loop below so that each pixel's red value will be set to 0 .
The method below takes a string parameter called str. Complete the method so that it returns a new string where each each character in the original string has been repeated 3 times. For example if the string given is "cat", the string returned should be "cccaaattt". Finish the nested for loops so the method behaves correctly.
The following method takes a list of strings as a parameter and returns the number of times the character 'e' appears in all of the strings together. It uses an outer loop to repeat over all the positions in the list, and an inner loop to repeat over all the character positions in one string. Complete the two loops so the method operates correctly. For example, if the list given is ["peter", "enter", "new"], this method would return 5. Your Answer:
This method below currently sets the color of all of the pixels in the given Picture to black. Modify the appropriate loop so that instead, it only sets the pixels on the left half of the image to black. In other words, all pixels with an \( x \) coordinate less than half the width should be set to black. Finish the for loops below \( s 0 \) that the method.