Algorithms and OOD (CSC 207 2013F) : Labs
Summary: In this laboratory, you will read, attempt to understand, run, and occasionally correct some Java code.
Prerequisite Knowledge: Using Eclipse. Java basics.
Fork the GitHub repository for this lab, available at https://github.com/Grinnell-CSC207/lab-code-reading.
Clone your fork to the local machine.
Import the clone into Eclipse. Note: This clone is already configured as an Eclipse project, so you can selectrather than .
Look at the
Main class and predict what the program
is supposed to do.
Confirm your hypothesis experimentally.
Look at the
MathUtils class. You may note that it's
badly formatted. Find a quick way to reformat it according to the
Java formatting conventions.
Return to the
Main class. Insert code to print the squares
of the real numbers 0.1, 0.2, ...., 0.9. When typing, type slowly and
take advantage of the popup menus that appear.
There's a small error in
Correct that error.
Commit and push your changes.
Introduce some syntax errors into your Java code and see how Eclipse reacts. In each case, you should see a red x at the left of the pane. Click on the x to see what options are available. Here are some suggestions:
intfrom the declaration of
ioutside of the for loop.
squareon a String.
returnfrom the body of one of the versions of
Pick a simple C program you've written previously and attempt to rewrite it in Java.
Copyright (c) 2013 Samuel A. Rebelsky.
This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.