Homework 1: Computer Programming

Instructions to submit to https://autolab.cs.jmu.edu from off-campus via sslvpn

Objectives

  • Display output with print, println, and escape chars.
  • Identify and correct errors from a Checkstyle audit.

Exercise 1.1   Hello World

Write a program named HelloWorld.java that displays the message Hello, World! exactly as shown. The point of this exercise is to set up your development environment and become familiar with Autolab. To get full credit, your submission must also pass Checkstyle rules.

Exercise 1.2   Fight Song

Write a program named FightSong.java that prints the JMU Fight Song lyrics:

Madison, James Madison,
We are the Dukes of JMU
Madison, James Madison,
The fighting Dukes of JMU
Fight for Glory-- Honors Won
Brighten the Lights of Madison
Madison, James Madison,
Show your Colors
Proud and True
We are the Dukes of JMU

Each line should be a separate println statement in the code. Your output must match the above text exactly, character for character.

Exercise 1.3   Harry Potter

Write a program named HarryPotter.java that outputs the following quote from Harry Potter and the Chamber of Secrets:

"It is our choices, Harry, that show what we
truly are, far more than our abilities."
        - Albus Dumbledore

The whitespace before the hyphen must be a single tab character. (Notice that most environments, including web browsers, display tabs as eight spaces.) Use appropriate escape sequences so that the output matches exactly.

Exercise 1.4   ASCII Art

Write a program named Flower.java that draws the following ASCII art exactly as shown. Notice that each line begins with a space, and there are no extra spaces at the end of each line.

   /\
 \ \/ /
 /  |  \
    |
  ------
 /      \
 |      |
 \      /
  ------

Exercise 1.5   Famous Quotes

Write a program named FamousQuotes.java that displays the Top 10 James Madison Quotes using this format:

Top 10 James Madison Quotes (according to brainyquote.com)
----------------------------------------------------------
[10] The essence of Government is power; and power, lodged as it must be in human hands, will ever be liable to abuse.
[9] The truth is that all men having power ought to be mistrusted.
[8] The advancement and diffusion of knowledge is the only guardian of true liberty.
[7] What is government itself but the greatest of all reflections on human nature?
[6] The people are the only legitimate fountain of power, and it is from them that the constitutional charter, under which the several branches of government hold their power, is derived.
[5] America was indebted to immigration for her settlement and prosperity. That part of America which had encouraged them most had advanced most rapidly in population, agriculture and the arts.
[4] Knowledge will forever govern ignorance; and a people who mean to be their own governors must arm themselves with the power which knowledge gives.
[3] Liberty may be endangered by the abuse of liberty, but also by the abuse of power.
[2] The happy Union of these States is a wonder; their Constitution a miracle; their example the hope of Liberty throughout the world.
[1] If men were angels, no government would be necessary.

Note that each quote ends with a newline character, and there are no line breaks in the middle of a quote. The point of this exercise is to learn how to format your source code without exceeding 80 characters per line.

Your solution must NOT use the + operator. Autolab will reject any submission that has a "+" character anywhere in the file.

Below is the full text for the above quotes:

Top 10 James Madison Quotes (according to brainyquote.com)
----------------------------------------------------------
[10] The essence of Government is power; and power, lodged as it must be in human hands, will ever be liable to abuse.
[9] The truth is that all men having power ought to be mistrusted.
[8] The advancement and diffusion of knowledge is the only guardian of true liberty.
[7] What is government itself but the greatest of all reflections on human nature?
[6] The people are the only legitimate fountain of power, and it is from them that the constitutional charter, under which the several branches of government hold their power, is derived.
[5] America was indebted to immigration for her settlement and prosperity. That part of America which had encouraged them most had advanced most rapidly in population, agriculture and the arts.
[4] Knowledge will forever govern ignorance; and a people who mean to be their own governors must arm themselves with the power which knowledge gives.
[3] Liberty may be endangered by the abuse of liberty, but also by the abuse of power.
[2] The happy Union of these States is a wonder; their Constitution a miracle; their example the hope of Liberty throughout the world.
[1] If men were angels, no government would be necessary.

Back to Top