Introduction to Programming (CPSC 124)
—Hobart & William Smith Colleges, Spring 2015
Thursday Lab #3
Home | Syllabus | Calendar | Class Notes | Labs and Projects | General Notes

Due by 12:19 pm on Friday, February 6

Topic Review

The Programming Problem

Write a program, ValidDate, which is invoked with three integer arguments, representing the year, month, and day (in that order) of a calendar date. The program should print true if the specified date is a valid one in the Gregorian calendar (that is, the standard calendar in use throughout all Western countries). Otherwise, it should print false.

Some essential aspects of valid calendar dates:

Example interactions

John-Lasseter:~ jlasseter$ java ValidDate 2015 2 5
true
John-Lasseter:~ jlasseter$ java ValidDate 2012 2 29
true
John-Lasseter:~ jlasseter$ java ValidDate 2015 2 29
false
John-Lasseter:~ jlasseter$ java ValidDate 1492 6 14
false
John-Lasseter:~ jlasseter$ java ValidDate 2015 3 47
false
John-Lasseter:~ jlasseter$ java ValidDate 1900 2 29
false
John-Lasseter:~ jlasseter$ java ValidDate 2000 2 29
true
John-Lasseter:~ jlasseter$ java ValidDate 2015 6 31
false

YOUR JOB

The goal of this lab is to give you some experience with the material we discussed in class on the separation and delay of concerns during program construction.

Build your ValidDate solution by constructing a series of Java programs that solve increasingly larger parts of the overall problem. There is no single way to do this, so don't worry if your series of problem simplifications/solution expansions is different from mine or others in the class.

The most important part of this lab is that you document your development process. You will do this by describing each stage in your program development, that is, a description of the portion of the problem you're going to solve and the source code for your program that solves this problem.

You will save this documentation in a single file, for which you may use any word processor (MS Office, LibreOffice, etc.). To construct your document, follow these steps:

  1. First, identify an initial outline of the programs's major stages (if you're looking for guidance here, use the material in the February 4 class notes). For example, your program might only solve the problem of printing an answer true for all inputs. It might do nothing other than read its three arguments. It might simply do nothing when it runs. Really, this choice is up to you. Write down what this simplification is; in other words, state clearly what portion of the overall problem your program solves.

  2. Make a complete Java program that correctly solves this version of the problem. This must be a legal Java program! I cannot overstate how important this is. If you cannot compile and run your source code, then you don't have a solution.

  3. Copy and paste this source code into your development document.

  4. Have you finished? Does your program now solve the problem completely? Does it produce the expected results for the example inputs you've chosen? If so, congratulations. Tidy up your lab report, and submit the source code for the final version of your program.

    Otherwise decide on an improvement to your solution, that is, a slightly more complete solution to the problem. Go back to step 2, and repeat!

Summary of Expectations

Turn in (READ ME):

Turn in a paper copy of your lab write-up. Since that will include every version of your program, you do not need to give a separate paper copy of your final source code.

Submit an electronic copy of the final version of your program (no need to submit the earlier ones, as I can reconstruct them from your lab writeup). Remember to copy this to your turn in folder:

/classes/cs124/<your last name>/

NOTE: Make sure you're actually copying it to this folder and not your own home folder at /afs/afs.hws.edu/home/<your user name>! This is an obvious source of confusion, and will lead you to think you've turned in your work to me when you haven't.

Also, please respect my file name requests. I ask for precise names because it makes it easier for me to test your work. Thanks.


John H. E. Lasseter