CSC 012N

INTRODUCTION TO COMPUTER SCIENCE

 

Instructions for Creating and Running Your Program

  1. Run your favorite editor (e.g., Ultra Edit) or word processor (e.g., Microsoft Word).  Type in the Java code.

  2. Save the program you've constructed to a text file, Filename.java.   NOTE:  Remember to name your file with the same identifier as your program or class.  That is, if your program begins:

public class MyClass
{......

then, save your program as:    MyClass.java.  If you use a word processor, be sure to save the program as a text file, NOT as a Word file.

  1. Run the MS-DOS prompt window.

  2. At the prompt, type javac followed by the filename as follows:

>javac Hello.java

This tranlates the Java source code into Java Bytecode.  That is, I have created a new file called Hello.class.

  1. Now, type java followed by the class name as follows:

>java Hello
Hello World!

The program has been executed.

Instructions for Handing in Homework

There are two ways to give me your homework assignments:

  1. (Hard Copy)
    You should hand in your source code as well as your output from your program.  If you have keyboard input, you should have your program echo the input to the screen so that you can see it on output.  For example,

    x = Keyboard.readInt ("Number Please");
    System.out.println (x);    //copies the keyboard input to the screen

    To create an output file that you can print, you can invoke your program as follows:

            java Program > Program.out

    This will send the output from your program to the file Program.out instead of to the screen.  This is called "redirection" of output.   Then print both Program.java (your source code) and Program.out (your output) and hand them in.

  2. (E-Mail)
    Just send me a message and attach your source code file (Program.java) and output file (Program.out)

 

Homework Assignments

 

Back to CSC 012N Home Page