COMP 14-090 Summer I 2000

Assignment 1b: Hello World

Assigned: Tuesday, May 23
Due: Thursday, May 25

Description

This exercise will give you a gentle introduction to Java and Visual J++. You are free to work in groups on this assignment.

What to Turn in:

Steps to Follow:

  1. Follow the instructions in Getting Started with Visual J++ under "Creating a New Project."  Use Assignment1b as your project name.
  2. Follow the instructions under "Adding a New Class."  Name your class WorldGreeter.
  3. Enter the text of the Hello World program (attached). Or you can save time by copying the text from the course web page (WorldGreeter.java under "Sample Code"). To copy from the web, bring up the web page, select Select All from the Edit menu. Then select Copy from the Edit menu. Then go back to the Visual J++ program text window and select Select All from the Edit menu and then select Paste from the Edit menu. That should put the program text into your Visual J++ window. Make sure you copy everything exactly. You are not expected to understand the code; just copy it. Later this week, the mysteries will be revealed.
  4. Follow the instructions under "Building the Project" and "Running the Program."
  5. Did your program run correctly?
  6. Congratulations: you have now created and run your first Java program!

// WorldGreeter.java

/******************************************************************
 * Assignment 1b: Hello World Java Program
 * 
 * Programmer: [Insert your name here]
 *
 * Due Date: May 25, 2000
 * 
 * Class: COMP 14         Instructor: Michele Clark
 *
 * Pledged: I have neither given nor received unauthorized aid
 * on this program.
 *
 *
 * (Signed)__________________________________________________
 *
 * Description: This program prints out a greeting to the world.
 *
 * Input: None
 *
 * Output: A friendly greeting
 *
 ******************************************************************/

public class WorldGreeter
{
	public String greetWorld () 
	{
		return "Hello World!";
	}
	
	public static void main (String[] args) throws java.io.IOException
	{
	    // create an object of the WorldGreeter class
	    WorldGreeter greeter = new WorldGreeter();

	    // output a greeting
	    System.out.println (greeter.greetWorld());

	    // mark the end of the program
	    System.out.println ("\n==> End of job");

	    // wait for an Enter press before closing the window
	    System.in.read();
	}
}

Michele Clark
clark@cs.unc.edu
Last modified: Wed Oct 23 2002 15:19:43 GMT-0400 (EDT)

Back to COMP 14