COMP 110 Spring 2011

Lab 3

25 points

Assigned: Friday, February 4
Due: Friday, February 11 by 1:00pm


Lab 3 will introduce you to Java applets, flow charts, and if-else statements. You have been given a skeleton program that can be found on the course webpage. Copy the program into Eclipse, and compile and run the program. When you run the program you will have to input a String before you will see the Java applet appear. (You will use this input for part 2)

Part 1

At the beginning of the program you will notice that there are many Named Constants. Notice that the identifiers are in ALL_CAPS. Go ahead and change the values of some of the Named Constants and recompile to see what changes you have made to the program. Make sure to change the constants back to their original values before continuing to part 2.

Part 2

For this part of the lab you will modify the code so that is follows the flow chart.

The flow chart may look daunting so take it one branch at a time. Take a look at the code that has been given to you and notice there are comments about where you should start your code. You will not have to change any code before the comments or after them. I have already given you code that reads in the user input (as a String), so all you need to do is write the multibranch if/else statements. Also, the only variables you will need to change are noseDiameter, eyeColor, and mouthStartAngle. Do not worry about error checking. If the user inputs the incorrect thing, the original smiley will display without any changes.

I recommend you start with MOUTH because it is the easiest case.


How to hand in the assignment