Station 1: Constructing Code

AS A GROUP, construct the code to match the output provided at the SAME TIME Don’t split up the work! What strategy did you use to help you construct the code correctly? Add any additional reflections on what you learned in this station.

The strategy I used to construct the code was to work from top down. I knew that the class Main and public static void main needed to be near the top. The closing brackets had to be at the end so I moved them down out of the way. After that I looked for anything that needed to be initialized like a Scanner or in this case, an int variable and an int array. Since I knew the format of an array, I could look for the blocks of code that I needed. I then saw that I had a for loop to construct. Since for loops follow a very predictable structure, I was able to find the pieces that I needed. I knew that this for loop was supposed to add all the numbers up as the output was the sum of the numbers in the array. So, I put the adding part of the code inside the for loop. Finally, there were only three blocks of code left, so it was easy to create the output line. I really think going top to down helps with the code. I’d first look for any imports and then the two lines that usually come after it. After looking for anything I need to initialize, I then can see what I actually need to do with the code. This helps get a lot of the obvious code blocks out of the way.

Station 2: I’m a Compiler/JVM

AS A GROUP, review the code and pretend you’re a Compiler and Java Virtual Machine. Identify the error by:

  1. Identifying whether if it’s a Runtime or Syntax error
  2. fixing the error
  3. adding your OWN custom error message

Which errors were the hardest to spot? Why? Add any additional reflections on what you learned in this station.

The hardest errors to spot was the first one on indexes and the last one where the inequality sign was set up wrong. The first one was hard to spot at first since I wasn’t too familiar with arrays. It’s hard for me to visualize how arrays and their indexes work in my mind. The inequality sign on the third slide took a while as well. I figured it out when I remembered that I typically didn’t see an equal sign in that second part of the for loop. This station showed me how easy it is to make mistakes in my code and the difficulty it could take to spot the errors. One equal sign could cause the entire code to stop. It was helpful having a partner as they could notice errors that I might’ve overlooked. It might be helpful in the future to take a break from coding to get a look with fresh eyes or to get someone else to view my code.

Station 3: Trace Tables

INDIVIDUALLY, fill out the trace tables by writing the value for each variable when it is outputted to the screen (System.out.println) AS A GROUP, compare your results with each other and discuss any values that do not match in the tables Which code trace table gave you the most difficulty? Why? Add any additional reflections on what you learned in this station.

The part that gave me the most difficulty was the second slide. It was already hard to visualize a single for loop, so when there is a nested for loop it became much harder to trace the code. After getting over the initial feeling of being overwhelmed, I found it helpful to get a piece of paper out, and work through the loop. Going line by line really helped as it made it much easier to keep track of what value the variables had. This station was helpful in familiarizing myself with for loops. The first slide showed me how if statements could be used in for loops and the second showed me how the variables change in nested for loops. With the practice I got from this learning station, I feel like I could do multiple nested for loops and if statements as I understand them much more than I did before.