Activities

To improve your conditioning in terms of Java conditionals, review the topics of this hour with the following activities:

  • Remove the break statement from one of the lines in the ClockTalk program, and then compile it and see what happens when you run it. Try it again with a few more break statements removed.

  • Create a short program that stores a value of your choosing from 1 to 100 in an integer variable called grade. Use this grade variable with a conditional statement to display a different message for all A, B, C, D, and F students. Try it first with an if statement, and then try it with a switch statement.

To see Java programs that implement these activities, visit the book's website at http://www.java24hours.com.

Get SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH EDITION now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.