Introduction to Programming (CPSC 124)
—Hobart & William Smith Colleges, Spring 2015
Thursday Lab #1
Home | Syllabus | Calendar | Class Notes | Labs and Projects | General Notes

Due by 12:19 pm on Monday, 01/26/2015)


The goal of this short assignment is to familiarize you with the basics of our campus Linux system, in particular the basics of command-line use of the Linux machines and the conventions we will use for turning in work in this class.


Exercises: Linux

To complete this lab, you'll do some exploring to find out a little more about Linux. You should put your answers a file named lab1-writeup.txt. (Use gedit, Komodo Edit, or any other text editor or word processor to edit it.)

  1. Write a paragraph or two to accompany your other answers, telling me the following:

    • your name, and what you prefer to be called (if different)
    • your major and minor if you've declared them, or what areas you are considering
    • why you are taking this course
    • any computer science or programming courses or experiences you've had
    • whether you think of yourself as a "computer person" - do you feel comfortable using computers, are you often successful at figuring out new things using computers, etc
    • whether you think of yourself as a "math person" - do you feel comfortable working with basic geometry (shapes and coordinates) and simple equations?
  2. Now read the tutorial document, "Introduction to the Math/CS Linux System", available from the "General Notes" section of our class web page. Work your way through the steps in this document. You should be able to finish the last step where you submit an "assignment". This is the basic mechanism you will use for all your work this semester.

  3. For each of the following, give the full path name for the file or folder mentioned. If shortcuts are possible, list those too.

    1. Your lab1 folder.
    2. The lab1-writeup.txt file where you are writing these answers.
  4. Answer the following questions using the information on the Using Linux at HWS web site:

    1. If you accidentally put a file in the trash, you can restore it. But what if you accidentally delete something from the trash, or use "Delete" instead of "Move to Trash"? Is there anything you can do to get that file back? Explain.

    2. If your computer crashes, why shouldn't you just reboot it? Explain, and list two strategies for fixing problems without rebooting.

  5. Explore Linux and Cinnamon. Quite a lot about the environment is configurable - you might check out what you can configure under Preferences, Preferences->Cinnamon Settings, and System Tools->System Settings on the Applications menu. You might also check out what applications are available, or what other information is available in the Using Linux at HWS pages. Write at least two paragraphs about what you've found/learned.

  6. Paste the following Java program into a new source code file:
        Given a temperature (in degrees fahrenheit) and a wind speed (in mph), 
        display the perceived air temperature felt by a human body on exposed 
        skin.  Note that the underlying mathematical model only works for air 
        temperatures at or below 50 degrees F and air speeds above 3.0 MPH.  
        You'll get get nonsense answers for warmer air temperature values or 
        slower wind speeds;
    public class Windchill {
        public static void main(String[] args) {
            double temp = Double.parseDouble(args[0]);
            double wind = Double.parseDouble(args[1]);
            double v2 = Math.pow(wind,0.16);
            double windchill = 35.75 + 0.6215 * temp 
                                + (0.4275 * temp  - 35.75) * v2;
        } // main
    } // Windchill

    Compile this program at the command line, using Java language compiler, javac:

    John-Lasseter:~ jlasseter$  javac

    and run it, using the Java runtime environment and two arguments, both numbers, separated by spaces. Do this to check to check the windchill at 21 degrees fahrenheit, with a 13.5 mph wind:

    John-Lasseter:~ jlasseter$  java Windchill 21 13.5
  7. Write short answers to the following questions. Note that it is okay if you don't get these answers exactly right! The purpose is not to quiz you on material you've never seen before but to guide learning through investigation. You will only be assessed on the care an thoughtfulness of this investigation. The "right" part will come naturally, very soon.

    1. What happens if you invoke the program with fewer than two arguments?

    2. More than two?
    3. What happens if the program is invoked with arguments that aren't numbers?
    4. What happens if you reverse the order of the arguments?

    5. Based on the observations of questions a-d, what do you conclude about the purpose of args?

    6. Based on the observations of questions a-d, give a short explanation of the used of Double.parseDouble(): what it requires in order to work, what its limits are, and what it does.

    7. There are four names (a.k.a. "variables") used in this program: temp, wind, v2, and windchill, and each one is first introduced in a declaration statement (beginning with "double" and ending with ";". Try reversing the order of any two of those statements. What happens?

    8. This program's central calculation is based on the customary North American/UK formula (for example, here). Which part of the program calculates the sub-expression V0.16?

    9. In our first class, we discussed the organization of all programs into view> (what the user sees), model (how the interesting parts of the problem are represented inside the pgoram), and control (the mechanisms for communicating information between the view and the model. In a few sentences, explain how these three ideas are represented in the Windchill program: what parts of the program constitute the model? What is the view? What parts of the program serve as the control?

Don't forget to follow the steps to hand in your lab (again) when you are done! Also, remember to reboot your computer when you leave the lab (or log out if you are in the Lansing lab).

Turn In

John H. E. Lasseter