Programming Assignment Checklist: Loops


Frequently Asked Questions

What are the goals of this assignment? To write several small Java programs so that you get accustomed to: using conditionals, loops, and to debugging your code.

What preparation do I need before beginning this assignment? Read Section 1.2 and 1.3 of Intro to Programming. You may also find it instructive to work through some of the other exercises and look at the solutions on the booksite afterwards.

How should I format my Java code? Follow the style from lecture and the booksite.

For Ordinals.java, what are the rules that dictate when to use "st", "nd", "rd", or "th" for printing the ith Hello? Any integer that ends in 0, 4, 5, 6, 7, 8, or 9 should always be followed by "th". Any integer that ends in 1, 2, or 3 should be followed by "st", "nd", or "rd", respectively, unless it ends in 11, 12, or 13 in which case it should be followed by "th".

For Ordinals.java, if the input is N, how many lines of output should I have? N.

What exactly is a 4-by-4 checkerboard? It has a total of 16 asterisks, 4 per row. Each row has 8 characters, alternating between asterisks and spaces.

* * * *
 * * * *
* * * *
 * * * *

What is meant by "high-level description of your code" in the readme file? Give a general overview of how you instrumented your program. Here's an example for Average.java.

I use Math.random() to generate values between 0 and 1, one at a time, without
storing them. After generating each value, I update two variables: N, which
counts the number of data values, and sum, which stores the cumulative sum.
Upon termination of the loop, the average is sum/N.

Testing

Reference solutions. To help you check your work, we have provided reference solutions (the .class files, not the .java source code) to the exercises. Simply download the relevant .class file from the solutions directory and execute as normal. For example to run the program contained in Checkerboard.class, type

% java Checkerboard 4
* * * *
 * * * *
* * * *
 * * * *
Note that when you compile Checkerboard.java, it will overwrite any other version of Checkerboard.class in the current directory. Thus, to save our reference solutions, you should store them in a subdirectory too, say solutions.

Submission

Submission. Name your programs exactly as we specify, being careful to use the same capitalization.

readme.txt. As always, download our template readme file and answer any questions. It is the file named readme.txt in the directory loops.

Enrichment

Here are some famous and not-so-famous quotations about learning to program.



COS 126 Assignments
Kevin Wayne