Week 10
This week we had a Histogram Java
coding assignment. It had been a few weeks, perhaps even two or three months
since I have code an assignment or a project. I had to relearn a few things,
but it was not too bad. I was able to start remembering the Java syntax after
writing some lines of code. I had forgotten how try catch works and I spent a
few minutes reviewing that. I had never used the StringBuilder class before and
it was interesting to learn that and it made the display() function work
easier.
The most difficult part of this
assignment was the display() function, I spent a few hours by trial and error
figuring out the printf(). It was challenging to figure out a way to print the
histogram. I had to take a break for a hour or so. When I returned to give it, after
another try somehow I was surprise to come up with the idea of using the
StringBuilder to append the next letter to print base on the number of
occurrence if it was equal or greater the highest number of occurrence. I used
a for loop to decrement one each time from highest number of occurrences. Each
time appending each letter from least to greatest. I was very happy to see the
output working correctly.

Comments
Post a Comment