preview

Pt1420 Unit 1 Assignment 1

Satisfactory Essays

7. Section A (5 points) a. Debugging process: Minimum element was initially zero, which resulted in a wrong output. Using the debugger to check how For-Loop iterated, I found the initial problem of min = 0 that caused IF statement to be always False. Thus, I changed min=0; to min=num[0] and the program begun to work perfect. 8. Section B (15 points) a. Debugging process: When I used the debugger, I found the code was not shrinking the image. The For-loop was not functioning, so that I changes the variable to smaller.length. Moreover, I multiplied the variables of i and j by two, which made the image size down ¼ of the original size. However, the colors were fading away because of my changes of coding. By using the debugger, I fund that my For-loop had the wrong …show more content…

After running this program, an error message appeared when the number of people became zero. The computer did not accept the division when the number of cookies was divided by zero (min=0). Moreover, the numbers of leftover cookies were wrong when I used the debugger. Because the calculation of cookiesLeft was not correct, I made the following change. cookiesLeft = numCookies – numPeople  cookiesLeft=numCookies – numPeople*cookiesPerPeople 10. Section D (10 points) a. Debugging process: When I first ran the coding, the program was not working. Using the debugger, I found out that the program was not reading the file. By looking into the variables, I noticed that the some data were missing. The following is the list of my correction to fix the coding. -Declared the Strings to print outside of IF statement, added IF statement to check if the data were missing, and then, set the missing data to “-“. -Worked on month and dayNum by declaring the variables first. Checked if third index is empty, then set empty data to “-“. Else, filled the variables with the correct

Get Access