School of Engineering and Applied Science
Department of Computer Science
CSci 53 -- Introduction to Software Development
http://www.seas.gwu.edu/~csci53/fall02
Prof. Michael B. Feldman
mfeldman@seas.gwu.edu

Lab Exercise #5
for labs meeting Tuesday Oct. 8, 2002

Objectives: This lab will help you understand if statements and switch statements.

Copy and compile programs53/DateOps.java and programs53/DayTest.java. Now run DayTest. You'll notice that DayTest returns a number from 0 to 6. In this lab you will write two versions of DayTest (DayTestIf.java and DayTestSwitch.java). In DayTestIf.java, rewrite DayTest.java so that it returns the string representing the day (i.e. "Monday") instead of the number (i.e. 1). Solve the problem using if statements. In DayTestSwitch.java, do the same thing, but this time use a switch statement instead of if statements.

Notice that you have now solved part of your problem for the next project. You should be able to take the ideas you worked out in this lab and apply them to your own project code.

Print out copies of DayTestIf.java and DayTestSwitch.java and staple them to this lab handout for reference.

(end of lab)