CSC 171 LAB #1

FALL 2001

 

GOALS:

·         Become familiar with the emacs editor

·         Become familiar with the code-compile-run cycle

·         Compile and run the “Hello World” JAVA application

·         Modify the “Hello World” JAVA application

 

TASKS:

1. Hand in the sheet with the answers to the emacs questions.

2. Demonstrate the modified application to your lab TA.

 

STEPS:

1.        Emacs is a text editor – a computer application which allows users to create, modify, and save text files on a computer’s file system. Your lab TA will demonstrate how to start emacs. On the Taylor 31 machines, this is accomplished by navigating to emacs via the Start->Programs->Programming->emacs button.

                                                                           i.      Once you have started emacs navigate through the Help-emacs tutorial menu. Read through the tutorial and follow all the instructions. (The tutorial should take less than 30 minutes.)

                                                                          ii.      Answer the following questions and hand the results into your lab TA. Don’t skip the tutorial, because questions like these about emacs will be found on the first exam.

 

1.        What does “C-<chr>” mean? __________________________________________

__________________________________________

2.        How do you end the emacs session? __________________________________________

      __________________________________________

3.        What does “C-L” do? __________________________________________

      __________________________________________

4.        What are the forward and backward commands? __________________________________________

      __________________________________________

 

5.        How do you move to the beginning or end of the entire tutorial? __________________________________________

__________________________________________

6.        How do you insert text in emacs? __________________________________________

__________________________________________

7.        How do you delete text? __________________________________________

__________________________________________

8.        What does “C-x C-f”” do? __________________________________________

__________________________________________

9.        What does “C-x C-s” do? __________________________________________

__________________________________________

10.     What does “C-h a” do? __________________________________________

__________________________________________

__________________________________________

 

2.        Use the “C-x f” command to open an empty file called “program1.java”

                                                                           i.      Recall the “hello world” program from lecture

public class program1 {

      public static void main(String[] args) {

            System.out.println(“Hello CSC171”);

      }

}

 

                                                                          ii.      Type the sample text into the program1.java buffer

                                                                        iii.      Save the program

                                                                        iv.      Compile the program using the JDE menu JDE->compile

                                                                         v.      Fix any problems due to typos that you may find

                                                                        vi.      Once you get a good compile, run the application using the JDE menu JDE->Run app

                                                                      vii.      Congratulations, you have written your first JAVA program

 

3.        Modify your buffer

                                                                           i.      Change “Hello CSC171” to “Hello <your full name>”

                                                                          ii.      Compile and run

                                                                        iii.      Add a second line below the System.out.println line, exactly like the System.out.println line except instead of the “hello” string, put in the question “Do you like to program?”

                                                                        iv.      Add a third line which writes the String “What do you suppose the definition of the word “is” is?”.  (Hint - textbook p. 64).

 

4.        Ok, you are done to get credit for all this work you need to get a piece of paper ready for your lab TA. This paper must have 3 things on it.

                                                                           i.      Your name and lab section

                                                                          ii.      Questions and answers to the 10 emacs questions above (Cut and paste - you get zero credit for the lab if you don’t do this)

                                                                        iii.      Your final version of the modified program.

 

5.        When you get the paper ready call your lab TA over and run the program for her/him. (This is called “demoing”). Give the paper to your TA. This completes the hand in process. The deadline is one week – no late assignments accepted.