Assignment 1

Due Before class on Oct 10th.

  1. As soon as you can, send me a brief email message to allow me to add your email address to my list. You can combine the other three parts of the assignment below into one message.

  2. Read the covenant and let me know next Thursday or before by email if you have questions or disagreements.
  3. Get a Java developement environment setup on the machine you will be using for programming projects. The ACC Lab in the Computing Center is already set up and ready to go (ask the lab trolls for help). If you want to install it yourself on your computer at home or work, go to the Java 2 Standard Edition (J2SE) download page and download and intall the software developer's kit (SDK), not the Java Runtime Environment (JRE). The SDK includes the JRE. The download page includes detailed installation instructions for each platform. Make sure you read it carefully if you have any problems.
  4. Try to to post a Java applet on the web using your account on grace.evergreen.edu or another reliable server if you are already familiar with it. You could start with one of the samples from the web page.

  5. Find a good Java reference that has plenty of examples of code you can get ideas from. I learned Java from The Java Tutorial which I have bookmarked in my browser. I use it so much I downloaded the HTML code from the website onto my local machine. The tutorial is also available as a PDF file or as a printed book.
  6. Write a Java applet that prints out a multiplication table. I suggest doing it step by step.

    1. Take HelloWorld.java and change the name of the file then be sure to make the name after class on the first line match the name of the file (without the .java).
    2. Compile that and run it to make sure you're starting from something that works.
    3. Wrap the System.out.println() function call with a for loop. Recompile and try it out. It should print "Hello World" out as many times as you set up the loop to repeat.
    4. Change the System.out.println() call to print out the variable you are using in the for loop to count. Recompile and test.
    5. Wrap that whole for loop with another for loop. Be sure to use a different variable name for the new loop. Now you have "nested loops". Recompile....you get the idea.
    6. Try printing out the value of the new loop counter variable you just created too. For example, if you used i and j try: System.out.println(i + ", " + j);
    7. Now make it do a multiplaction table. The asterisk (*) is the multiplication operator. You can use System.out.print() (print, not println) to print out a number without going to the next line. Just calling System.out.println() with nothing in the parentheses will go to the next line (carriage return) without printing anything.

    If you get your table to print out properly and you still have some time, try to put the nested loops into a separate function which takes one argument: the width (and height) of your table. If you get that working and are still bored, try printing out the labels for the rows and columns of the table. Make it print out something like this:

     X | 1  2  3  4  5 
    ---+--------------
     1 | 1  2  3  4  5      
     2 | 2  4  6  8 10
     3 | 3  6  9 12 15
     4 | 4  8 12 16 20
     5 | 5 10 15 20 25