Homework 02
Version 1

 

Due by 8:00 AM on Monday, September 13, 1998

  1. The following program has a variety of syntactic and other errors.

    /* 
      Program: HW02PR01
      Author:  Joshua S. Hodas /* A pretty smart guy! */
      Date:    September 26, 1996
      Purpose: To print the gettysburg address
    */
     
    class HW02PR01 {
     
      public static void Main(String args[]) {
     
        System.out.println("Four score and");
        System.out.print(21.0/3.0);
        System.out.print("years ago, ")
        System.in.println("our fathers brought forth on this ");
        System.out.println("continent a new nation.");
     
      }
     
    }
    

    Fix them so that it successfully compiles and runs and prints:

    Four score and 7 years ago,
    our fathers brought forth on this
    continent a new nation. 
    

  2. Write a program that will print:
    A program to print \n has at least 1 thing that is "hard to print",
    but one that prints \\ has at least 2! 
    
    The program should not contain any uses of the numbers 1 or 2 as numeric or string literals.

  3. Modify the program LiteralAreas from the lecture so that in addition to the areas of the square and circle, it also prints the volume of the cube of side 3 and the sphere of diameter 3.

The electronic submission system is now up. Follow the electronic submission directions to turn in your homework.

Last modified August 29 for Fall 99 cs5 by mike@cs.hmc.edu


This page copyright ©1998 by Joshua S. Hodas. It was built with Frontier on a Macintosh . Last rebuilt on Sun, Sep 6, 1998 at 1:11:30 PM.
http://www.cs.hmc.edu/~hodas/courses/cs5/week_02/homework.html