Program 0

 Due Date:   Lecture 8:   Monday, March 17
            Lecture 14:  Tuesday, March 18 

Program 0 is designed to give you practice editing, compiling, and executing a program.

If you need help using MS Windows, you may want to read our Introduction to Microsoft Windows. For help with Borland C++, check out our Introduction to Borland C++.

The Assignment

Between the rows of asterisks below is a program. You are to enter this program into the Borland C++ compiler and get it to run (see the tips below). Don't include the asterisks! The program will run as written so you don't need to modify it. We will probably discuss this program (or one like it) during the first week of class.

Please remember to put your login name (not your password!) and your real name in the places indicated in the program. Erase the words ``[your login name here]'' and replace them with your actual login name, and so on. There's no need to leave the [ ]'s in! (Your login name is what you use to get access to the computers; my login name is rmanning, for example.)

The Program:

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

       //CS110, Program 0
       //Section 8 (or Section 14)
       // [your login name here...]
       // [your real name here...]

        #include <iostream.h>

        void main()
        {
          int age, tiger_years;

          cout << "Please enter your age in years... ";
          cin >> age;

          tiger_years = age * 5;

          cout << "That makes you " << tiger_years << " in tiger years!";          
        }

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

Borland C++ 4.5 Hints

Log into your account, and start Borland C++ 4.5 which is found in the CSApps program group. Make sure you are using 4.5 instead of 4.0 -- your CSApps program group may contain both. When you have Borland up and running, you'll first want to create a file to write your program in. Click on File in the left corner of the screen, and choose New within the menu that drops down. An empty box will appear on your screen; this is where you will write your program. You will want to save your programs often. The first time you save it, choose Save as from within the File menu. This will ask you to name the file; call it ``program0.cpp''. The .cpp part indicates that this is a C++ program file. The second time you save, you can just choose Save and it will be done automatically. To access a file that you have previously saved to the disk, simply choose Open from the File menu and then let the computer know what file you wish to access.

Once you have the program typed into the file window, and you have saved the program in case something bad happens, you just need to press the little lightning bolt button near the top of the screen. Your program will be compiled, linked, and executed. If you miss-typed something, chances are you will get a syntax error. Go back to the program, check your typing, and when the mistake is found, change it and run the program again.

When the program runs, it will create a window and prompt you to enter your age (don't worry, no one's checking!). It will then print your corresponding age in tiger years. You'll know the program is done when the word INACTIVE appears at the top of the window.

Turning in the assignment

To turn in your assignment, copy it to your personal folder within the "handin" folder (see directions below). Each assignment specifies a due date and programs are officially due that day. However, see the "late policy" section of my CS110 homepage for more details.

One way to turn in your program is to use File Manager in the Main group. From within File Manager, locate the correct hand-in directory by first going to the r: drive and opening the handin folder (to open a folder, double-click on it--a little graphic image of an open folder will appear next to the folder name). Find the folder marked rmanning and open that. Inside you should see two folders: one labelled with your login name and the other labelled "examples". If you don't see both of these, talk to me. The "examples" folder will hold some sample programs and other files used throughout the course.

Open the folder labelled with your login name (your folder!). There's nothing in it now, but as the semester goes by you will keep adding programs to this folder. If you're ever wondering whether I've received an assignment, keep in mind that I see exactly what you see in your folder (so if you see your assignment there, so will I).

Now drop program0.cpp into your hand-in folder. One way to do this is: (1) make sure your personal folder is open, (2) switch to drive u:, (3) find your program0.cpp on drive u:, (4) grab program0.cpp with the mouse, drag it up to the drive r: symbol, and drop it there. Go back to drive r: and check that the program is in your hand-in folder.

Another way to turn in the assignment is by opening a second window in FileManager (use "New Window" under the Window menu). Have one window show drive u:, the other show drive r:. Grab program0.cpp in the drive u: window and drag it over to your folder in the drive r: window.

Another way to turn in the assignment is by using "Save As..." under the File menu in the Borland compiler.

It is important that you are able to finish all parts of this assignment. All the remaining assignments involve the same steps, only in the future you will write your own programs. Be sure to see me if there's something you aren't able to do.