ptg7068951
94 HOUR 7:Using Conditional Tests to Make Decisions
Answers
- C.Thebooleanvariable type only can equal trueorfalse, making it
similar to conditional tests. If you answered A.,I’m sorry,but there’s
only 17 hours left and we’ve got a lot left to cover. Java doesn’t teach
itself. - A.defaultstatements are handled if none of the other casestate-
ments matches the switchvariable. - B.The other answers describe conditioner and a confessional.
Activities
To i m p r ov e y o u r c o n d i t i o n i n g i n t e r m s o f J av a c o n d i t i o n a l s ,review the topics
of this hour with the following activities:
. Add//in front of a breakstatement on one of the lines in the Clock
program to make it a comment,and then compile it and see what hap-
pens when you run it. Try it again with a few more breakstatements
removed.
. Create a short program that stores a value of your choosing from 1 to
100 in an integer variable called grade. Use this gradevariable with a
conditional statement to display a different message for all A,B,C,D,
and F students. Try it first with an ifstatement,and then try it with a
switchstatement.
To s e e J av a p r o g r a m s t h a t i m p l e m e n t t h e s e a c t i v i t i e s ,visit the book’s website
at http://www.java24hours.com.