Wednesday, September 12, 2012

Chapter 3

As I was doing the reading for chapter 3 in our Pearson Custom Computer Science book, it seemed to all make sense to me. The chapter was on Selections (if statements, not, and, or, exclusive or, switches), and I thought everything was fairly straightforward, at least to me. I started on the CodeLab problems, and everything was going quite well. I was able to easily do all of the problems except for one involving a switch statement. The problem was to display a message if a number under 10 was prime, a different one if it wasn't, and another if the number entered was 10 or higher. For some reason, I could not for the life of me figure out how to get the 10 or higher one to work, as I couldn't say something like case >= 10 (if the number was greater than or equal to two) because that only works with true/false (Boolean) statements. Eventually, I realized that there's a special case called "default," which the program looks at if none of your previous cases are satisfied. I am a proud noob programmer right now. Lab and lecture tomorrow, expect more from me!

No comments:

Post a Comment