Debugging Exercise 5
Goal: debug the Pyramid.java
code.
From Java Bootcamp Resources
-> Module 2
-> 8\. Exception Handling
-> Debugging Workbooks
open the folder, exercise-five
.
If you can't find it, please download the updated resources from Github.
Debugging
The goal is to construct the following diagonal:
>>: a
>>:
>>: b
>>:
>>: c
>>:
>>: d
>>:
>>: e
There are nine rows. The diagonal must skip every second row and output the next letter every third row.
However, the starter code prints the following:
>>: b c d e f g h i j k
>>: n o p q r s t u
>>: z { | } ~
Yikes! Use breakpoints to visualize the runtime. Watching the output line by line will help you debug the problem.
Helpful Hints:
-
You can increment (++) characters from
a
toz
. -
The first letter starts with
b
when it should bea
. Fix that issue first. -
The inner loop is printing way too many letters. Look into its condition.