CS99

Fundamental Programming Concepts
Summer 2001

Lab 1

 

Overview
This lab will involve several Internet tasks and a small Java program. The goal is to introduce you to the Internet resources available in this class and help you to become accustomed to using these resources. You will: 
  1. Find information on a web page
  2. Write a program
  3. Send email
  4. Post to a newsgroup
Hopefully you are already familiar with some of the above tasks. If not, you will be soon!

Note that if you're reading this handout on a printed page, rather than online, you'll frequently see underlined words. These are hyperlinks that, when viewed online, can take you to pages with more information.

Part I: The Course Web page

The programs we'll be using in lab to access the Internet are supplied through Bear Access, a suite of programs that Cornell makes available. In Upson B7, you can start Bear Access by using the Start menu: Start->Programs->Bear Access->Bear Access via Runway. Bear Access supplies Netscape Communicator for a web browser, Eudora for email.  You may use Internet Explorer to access the Web page too.

  1. Use a web browser to go to the course website. The course website can be found at http://www.cs.cornell.edu/courses/cs99/2001su. Find the handout page for this lab. Follow this link to find the first secret phrase. And this link to find the second.  Make note of them -- you'll need them in Part II.

 

Part II: Java
For this course we will be using a compiler called CodeWarrior that is made by Metrowerks. It is an IDE, which stands for Integrated Development Environment. This means that the editor, compiler, and debugger are all part of one big program. 

Creating the Project

You will need to create a CodeWarrior project for each program you write. A project can contain several source files, libraries, and other items. To create a project for this lab, follow these instructions.

Don't forget that when you're done working for the day, you'll need to copy your project to a disk, and then logout of the machine you are working on (Start->Logout).


Your First Program

Now that we have the project created, let's write some code! Enter the following code in the Lab1.java file:

/**
 * CS99 Lab 1
 * Author: your name here
 * NetID: your NetID here
 * Date: today's date
 */
class Lab1 {
    public static void main(String[] args) {

        System.out.println("Hello, world!");
    }
}

Absolutely everything is important -- the spelling, capitalization, punctuation, etc. Now try to run your program. You can do this by doing any of the following:

  • Clicking the arrow on the Project window (4th icon to the right of "Java Application", turns green when you hover the mouse over it
  • Going to the Project menu and choosing Run
  • Pressing F5

If all goes well, you'll soon see a message on the screen saying "Hello, world!". Congratulations! You've written your first Java program. If not, you have your first bug to fix. The compiler will show you a list of errors. You can click on each error in the list, and it will take you to the statement in the program that the error is in. Try to figure out what you did wrong, correct it, and then try running the program again.

By the way, println is a method that prints a message to the screen. Its name stands for "print line". It is a method that belongs to the System.out object. We'll talk more about objects later. 


Your Second Program

Now it's time to write your own program -- the real one for this lab. This is the program you will submit. To prepare for it, keep your Lab1 program open. Get rid of all the statements inside main.

Write code that prints your initials to the screen. It should look something like this:

    A      JJJJJ   RRR   
   A A       J     R  R 
  A A A      J     RRR  
 A     A   J J     R R  
A       A  JJJ     R  R  
Your letters should be at least 5 rows tall.

It should print to the screen the secret phrase that you found on the course Web site in Part I.

Now rewrite your main method so that you the output is the following: 

 
first secret phrase
second secret phrase
    A      JJJJJ   RRR   
   A A       J     R  R 
  A A A      J     RRR                     <---- These should be your initials, not AJR
 A     A   J J     R R  
A       A  JJJ     R  R  

That's the first secret phrase, a blank line, the second secret phrase, a blank line, and then your initials. The blank lines can be produced with the following call to println:

System.out.println();
This is the only kind of call to println that your main method is allowed to make. Note that you could also make another method to do this, if you wanted. 

The program will be graded on these criteria:

  • Style
    • Correct indentation
    • Consistent brace placement
    • Comment at beginning of class
  • Correct output, as above
Print a copy of the file Lab1.java as well as the output from the program.
 
Part III: Email and Newsgroup
For this part of the lab, you will need to have your Cornell NetID and password. If you don't have these yet, you'll need to go to the CIT helpdesk located at the CCC building, and bring a photo ID with you. 
  1. Send email to the the instructor, Alan Renaud. His address is ajr5@cornell.edu. Use this subject: 
        "CS99: Lab 1 Roll Call" 
  2. (don't include the quotes). Include your name in the body of the message. If you've never sent email using your Cornell address, you'll want to make a Eudora floppy first. See the lab consultant in B7 if you don't know how to do this.
  3. Post to the course newsgroup. You can find news readers in Bear Access. The course newsgroup is cornell.class.cs099. You'll find a post in it with a subject of "Lab 1 Roll Call". Post a response to that message that includes your name. Since many people may not have posted to newsgroups, there is a separate set of instructions for this.
Don't neglect sending the email and posting before lab on Thursday! They will be part of your grade for this lab.

 

Part IV: Submit Your Lab
To submit your lab, follow the instructions on the separate handout about submitting labs.

Files to submit:

  • Lab1.java
  • Screen output from Lab1.java
Don't forget to submit your lab at the beginning of lab on Thursday!  Hand it in to Siddarth.