CS16, Winter 2018

Lab01:
Orientation


Goals for this lab

By the time you have completed this lab, you should be able to

Step by Step Instructions

Step 1. Create/verify your College of Engineering Account, and log on

By now you should already have a "College of Engineering" (CoE) computer account.

Only if you do not have a CoE account yet:

Log onto your account. If your username/password don't work - see troubleshooting login.

Open a terminal window. That's the Application Menu, then System Tools, then Terminal Window.

Notes:

Step 2: Create a cs16 directory and a lab01 directory

Create a directory named cs16 inside your home directory. Then create a sub-directory named lab01 inside cs16. Finally, cd into that directory and use pwd to verify before proceeding to Step 3. That is, execute the following commands (in bold) at the terminal prompt:

-bash-4.3$ mkdir ~/cs16
-bash-4.3$ mkdir ~/cs16/lab01
-bash-4.3$ cd ~/cs16/lab01
-bash-4.3$ pwd
/cs/faculty/mikec/cs16/lab01

The system's response (last line) will start differently for you, but verify the rest matches this example.

Step 3: Use an editor to create an ID file, and turn it in with turnin

Create a new file named id.txt using emacs or another editor available in the labs if you prefer (you might like gedit for example, but it only works in a graphical environment, so probably not if you are connected remotely). Here is some emacs help if you need it, and it contains a link to help with another common editor named vi too.

The contents of the file you must create are very specific. It should have exactly 3 lines as follows:

  1. Your official last name. By official we mean the name used by the registrar (and us) to identify you, and by last name we mean your surname (family name). If you are unclear about which name this is, then look it up in Gold or Gauchospace.
  2. Your official first name. Again we mean the name used by the registrar, not a nickname or anything else.
  3. Your complete email address. We prefer your umail address here if you have one.
Here is an example id.txt for the instructor. Notice no spaces at the start or end of any line, each line (including the last one) ends with a carriage return, and there are no blank lines. Save the file, and exit the editor when you are done.

Now you must turn in the file to help us identify you from your CoE account. Type the following at the prompt:

-bash-4.3$ turnin Lab01@cs16 id.txt

You should be asked if you want to turn in this file. Respond "yes", and then you should get a message indicating that your efforts were successful! Read the message, and redo whatever is necessary until you succeed. Here is the instructor's successful turn in (user input is boldface):

-bash-4.3$ turnin Lab01@cs16 id.txt

These are the regular files being turned in:

	    Last Modified   Size   Filename
	    -------------- ------  -------------------------
	 1: 01/13/18 10:09     35  id.txt

****************************************************************************

You are about to turnin 1 files [1KB] for Lab01 to cs16

*** Do you want to continue? yes
id.txt

*** TURNIN OF Lab01 TO cs16 COMPLETE! ***

Step 4: (Aside) Use a program named ch to try some C++

This section of the lab is mostly just for you to "wet your feet" writing a few C++ statements. It introduces you to all the C++ you'll need for later steps of this lab, as well as the first programming assignment (PA1). And we thought you should know about the ch program.

The program named ch at Phelps 3525 (and CSIL) can be used to execute C++ (and C) statements without writing and compiling whole programs. Type ch at the prompt to start the program:

-bash-4.3$ ch
                              Ch (64-bit)
                Professional edition, version 7.5.3.15401 
              Copyright (C) SoftIntegration, Inc. 2001-2016
                     http://www.softintegration.com
ch>

By default, the ch prompt is your current working directory. The prompt is simplified in these instructions. You can change it for a particular session by entering "_prompt = "ch> "" or to anything else you put between the quotes.

With C++ we use the cout object's insertion operator (<<) to print to standard output. Try it now (user input is bold in the following examples).

First print "Hi" to standard out as follows, then print it again with a newline (ch will also print its own newline each time):

ch> cout << "Hi";
Hi
ch> cout << "Hi" << endl;
Hi

ch>

Notice how the second statement uses the insertion operator twice, once to print the string "Hi" and again to print endl (a "stream manipulatator" meaning a newline).

Another way to print a newline is to embed a special character in the string you are printing. This character actually looks like two characters, because it begins with a special "escape" indicator, and altogether it is an example of an "escape sequence." The newline escape sequence looks like this: '\n'

Let's use a newline inside of a string to print the string on two lines:

ch> cout << "First line\nSecond line"; 
First line
Second line 

In that example, we just let ch add its own newline to the end of the string. In a program we would have added another '\n' at the end ourselves, or we would have followed the string with endl like the examples above.

By the way, ch is a great calculator. Try some calculations like the following:

ch> 5 + 18
23 
ch> 7 - 150
-143 
ch> 7.5 / 22 + 105
105.3409 

Print statements can include calculations too. Try this for example:

ch> cout << "I drove " << 65042 - 65028 << " miles."            
I drove 14 miles.

You can exit ch now (but remember it is available to try out simple things):

ch> exit
-bash-4.3$

Step 5: Create a submit.cs account, and join this class

If you don't already have an account on the submit system, make one now at https://submit.cs.ucsb.edu/form/user.

The Create New Account form will insist that you sign up using your umail address, and we insist you enter the name listed on the roster (not a nickname that you go by) - in fact, you should use exactly the same first and last names from id.txt that you created and turned in for Step 3.

Once you've created your account, login with the email and password you used to register. At the login page, follow the Join Class link, and then click the button labelled "Join CS16_w18_Costanzo" to join our class for this quarter.

If you need additional help with this step, see the first two sections of this help for submit.cs page.

Step 6: Select a partner for future labs/assignments

Choose a lab partner. The intent is for you to work together with this person in future labs, and optionally on programming assignments that allow it. An odd number of students in attendance will not be assigned a partner today - the TAs will make sure it is only one person. Ask a TA for help if you cannot easily find a partner.

Maybe this will be your first experience with "Pair Programming." If it is, then please try to pair with a student who is experienced at it. You will learn more about pair programming as the quarter progresses. In short, there are two roles: pilot and navigator. The pilot types, and the navigator helps by observing, inspecting, thinking and suggesting - but neither of you directs the other. You are helping each other so that you both understand the work.

The TA will have a sign-up sheet for you to note your partnership. Go together with your partner to sign that sheet before leaving the lab today.


Evaluation and Grading

Each student must accomplish the following to earn full credit [50 total points] for this lab:

Please do not pester the TA to be dismissed if you finish early. Instead, experiment with ch a bit more, help one of your neighbors if they are stuck, and/or begin working on PA1.


Prepared by Michael Costanzo.