Lab 1: Designing Functions
This lab introduces Metrowerks CodeWarrior environment that we will use in the labs and that you are advised to do your home works in. You will learn to write simple methods using the design recipe described in class and see some common error reports. At the end of the lab you will fill out a questionnaire and get a blackboard account for this class.
Part A: Getting Started
1. Get acquainted with the course web site: http://www.ccs.neu.edu/home/vkp/1101-sp03
2. Proceed to Lab Notes tab. Download Lab1.exe,extract files and save them in the folder Lab1.
3. Find Lab1.mcp - open it
4. Run the project - CTRL/F5.
5. Play with the GUI by evaluating areaOfDisk several times.
6. Test areaOfDiskTests.
7. Save console as .txt - print it: reliable 229. Submit the print out at the end of the lab.
Part B: Exploring Numbers and Arithmetic
Part B: Writing Code
/* compute the perimeter
of a rectangle, given the width and the height */
double perimeter(double
height, double width){
return (2 * height + 2 * width);
}
/* test the perimeter
function */
void perimeterTests(){
testHeader("Testing the perimeter function");
expected(100.0);
actual (perimeter(20.0,
30.0));
}
Part C: Questionnaire & Using Blackboard
Part D: Extras
1.
Use the function computeInt to determine
the result of the following expressions. Experiment with the expression to find
out what is the largest integer Java can represent.
i.16 * 16 * 16 * 16 * 16 * 16 * 16 * 16 * 16 * 16
2.Explore arithmetic - GUI with text input and eval button - like Interactions window
3.Design recipe for simple function
4.Primitive types: int, double, char, boolean
5.Explore relational and logical operators
6.Explore functions with if
7.Explore composition of functions