Jan 16 - Lab 3 - Algorithms Without Computers (Due: Jan 16)

Today's lab is 'paper-based.' I'll pass it out during class today. If you want a copy of your very own, you can download it here.

Jan 18 - Lab 4 - Entering and Compiling Your First Java Program (Due: Jan 23)

Enter the following program using the KDE Advanced Text Editor (KATE) -- located on the desktop of the lab computers. Save the program as a file called “Useless.java”. Filenames should always match the name of the class inside the file, including upper and lower case. Remember that Java is case-sensitive – you will cause yourself problems if you ignore this!

// A source of useless information.
public class Useless
{
   // Prints some simple messages.
   public static void main (String[] args)
   {
      System.out.println("Some useless facts:");
      System.out.println("Your ears never stop growing.");
      System.out.println("Catsup travels at 25 miles per year.");

   } // method main
} // class Useless

In the command box at the bottom of the editor, compile the program with the Java compiler (javac). At the prompt, type javac Useless.java. If you get errors, make sure that you typed the program exactly as it appears above. Note that when you are compiling a java program, you must enter the .java extension.

Once this completes successfully, list the contents of your directory in the command box (ls -l). You should now have two new files: Useless.java and Useless.class. The .class file contains the Java bytecode.

Execute the generated class file using the Java interpreter (java). From the command box, type java Useless. Note that when running a generated java class file, you do not need to enter an extension (.class or .java).

Find an interesting useless fact on the Internet (or dredge one up from your memory banks, or, for that matter, make one up). Add a line to the program that makes it print your useless fact right before the one about catsup. Put an comment in the program that lets us know the source of your “fact.”

Compile and execute the program again. Never assume that things work!!!.

Create an additional useless fact and have it print after the “fact” you added above. Instead of using the “System.out.println” method, print this line in sections using the “System.out.print” method. Make sure that the last segment of your phrase uses the “System.out.println” method, though (why, you might ask?).

Compile and execute the program again. Never assume that things work!!!

Place your .java file into a zip file. From the command prompt, type: zip lab4.zip Useless.java. Submit your zip file to the site using the submit mechanism. You will need to login using your JMU email name and password.

Check the screen to ensure that your submission was accepted. You may want to print out the screen and maintain your own record of successful submissions. Never assume that things work!!!