COMP 110-003 Spring 2013

Lab 3

30 points

Assigned: Thursday, January 31
Due: Sunday, February 10

Description

Lab 3 will introduce you to Java applets, flow charts, and if-else statements. You have been given a skeleton program Smiley.java 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 Smiley.java 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.

All the necessary methods that you are going to use have been introduced on lectures. Read the notes to know how to transform a String to an int, and how to compare Strings (You shall not use "==" to compare Strings).

Grading

How to hand in the assignment