ProgrammingExercise1_022417.pdf

Programming Assignment #1: Six Days of Christmas (15 points)

Program Description:

This program tests your understanding of using static methods and println statements. You

should write a Java class called SixDays that should be saved into a file called SixDays.java.

Your program should produce the following song as output:

On the 1st day of Christmas, my true love sent to me

a partridge in a pear tree.

On the 2nd day of Christmas, my true love sent to me

two turtle doves, and

a partridge in a pear tree.

On the 3rd day of Christmas, my true love sent to me

three French hens,

two turtle doves, and

a partridge in a pear tree.

On the 4th day of Christmas, my true love sent to me

four calling birds,

three French hens,

two turtle doves, and

a partridge in a pear tree.

On the 5th day of Christmas, my true love sent to me

five golden rings,

four calling birds,

three French hens,

two turtle doves, and

a partridge in a pear tree.

On the 6th day of Christmas, my true love sent to me

six geese a-laying,

five golden rings,

four calling birds,

three French hens,

two turtle doves, and

a partridge in a pear tree.

The song is a modified version of a classic holiday song. For brevity, we reduced the number of

days from the original twelve to six.

You should exactly reproduce the format of this output. This includes having identical wording,

spelling, spacing, punctuation, and capitalization. Please do not include additional verses, such as

writing twelve days to match the complete song. You may include a blank line at the very end of

the output if you like.

One way to write this program would be to simply write a println statement that outputs each line

of the song in order. However, such a solution would not receive full credit. Part of the challenge

of this assignment lies in recognizing the structure and redundancy of the song and improving

the code using static methods.

Stylistic Guidelines:

You should not place any println statements in your main method. (It is okay for main to have

empty println statements to print blank lines.) Instead of printing in main, use static methods for

two reasons:

1. To capture the structure of the song's six verses.

You should write static methods to capture the structure of the song. You should, for example,

have a method for each of the six verses of the song to print that verse's entire contents.

2. To avoid simple redundancy in the output.

You should use only one println statement for each distinct non-blank line of the song. For

example, the following line appears several times in the output, but you should have only one

println statement in your program that prints that line of the song:

a partridge in a pear tree.

However, a method that prints a single line such as the above is not useful. Instead, you should

identify groups of two or more lines that appear in multiple places in the song and create static

methods that capture those groups and are called multiple times. There is a general structural

redundancy to the song that you should eliminate with your static methods. Recall that methods

can call other methods if necessary. The key question to ask yourself is whether or not you have

repeated lines of code that could be eliminated if you structured your static methods differently.

As a point of reference, our solution to this program has twelve static methods other than main

and occupies 89 lines including comments and blank lines.

You do NOT have to eliminate redundancy in lines that are similar but not identical, such as

these:

On the 1st day of Christmas, my true love sent to me

On the 2nd day of Christmas, my true love sent to me

It is not possible to avoid this partial-line redundancy using just what we have learned so far

(static methods and simple println statements), so you are not expected to eliminate it.

Include a comment at the beginning of your program with some basic information and a

description of the program. The comments in your program should be written in your own words

and not copied from this document. You must comment every line and the comment should

explain what the code does and not simply what it outputs.

For example:

// Suzy Student

// Florida Tech 1502,Section XX

// Programming Assignment #1, 06/07/49

//

// This program's behavior is ...

For this assignment, you should limit yourself to the Java features covered in Chapter 1 of the

textbook. If you use concepts beyond Chapter 1, you will not earn credit.

Each programming assignment for the course will have the statement at the end that indicates

that the code is yours alone and you adhered to the academic integrity as outlines in the student

handbook.

Submission and Grading:

Turn in your screenshot in Word of the output with filename

JonBrownCIS1501ScreenShotsProgrammingAssignment1Jan122017 (your name, the course

name, the content of the file, and the date), SixDays.java and SixDays.class (Please make sure to

name your files exactly, including identical capitalization.) Then put all three files in one zip file.

The zip file should be named: your name, the course name, the content of the file, and the date

and then submit to the Assignments link on the course web page.

Part of your program's score will come from its "external correctness." External correctness

measures whether the output matches exactly what is expected. (We are very picky about the

output matching exactly. Every character and space must match.) Programs that do not compile

will receive no external correctness points.

The rest of your program's score will come from its "internal correctness." Internal correctness

measures whether your source code follows the stylistic guidelines specified in this document.

This includes having an adequate comment header, commenting every line, and capturing the

structure and redundancy of the song as specified previously.

    Leave a Reply

    Your email address will not be published.