[MSOE Homepage]

Dr. Taylor's MSOE homepage

Courses

Unix is a Four
Letter Word

My Photo Album

My Personal Homepage

CS-100 Main page

CS-100 -- Lab 1: Microsoft Visual C++

Fall Quarter 1999



Electrical Engineering and Computer Science Department
Dr. Christopher C. Taylor

S-331, 277-7339

www.msoe.edu/~taylor/

Purpose

In this lab, you will become familiar with the Build procedures for Microsoft Visual C++ 6.0.

Overview

You will:

  • In groups of three, develop an algorithm (in words) to solve the following problem:

    A bank account has a beginning balance of $10,000. Interest is compounded monthly at 6% per year (0.5% per month). Every month, $500 is withdrawn for college expenses. How many years will it take to deplete the bank account?

  • As a class, we will write a C++ program that implements the algorithm to solve the above problem.
  • Individually enter, compile, build, and test the program.
  • Individually report on your results and include the answers to a set of questions (see below).

Procedures

  1. Start the Microsoft Developer Studio; the procedure may be a little different depending on the computer you are using, but it often involves the Start menu in the lower-left corner of your screen.
  2. You may wish to create a folder for all of your CS-100 lab projects in the My Documents folder on your computer. You can do this with Windows Explorer.
  3. Create a new project called lab1.
    • Select New... from the File menu.
    • In the New dialog box, select the Projects tab (it may be selected already).
    • In the list on the left, select Win32 Console Application.
    • Enter the location where you would like your project be created (for example: C:\My Documents\CS100\) in the Location field. Do this first, before entering a name in the Project name field.
    • Enter lab1 in the Project name field. (Note: there is no requirement that the project name be the same as the main source file name, but many programmers like to do it this way.) Note that the Project name field changes to become c:\My Documents\CS100\lab1, the directory in which your project will be created.
    • Make sure the Create new workspace choice is selected.
    • Under Platforms, Win32 should be checked (it will likely be the only choice).
    • Click the OK button.
    • In the Win32 Console Application - Step 1 of 1 window, be sure that An empty project is selected and click the Finish button.
    • Click the OK button on the New Project Information window.

    This will create a new project called lab1 in the directory c:\My Documents\CS100\lab1 . If you look in this directory, you will see several files with names that begin with the project name (here, lab1), but don't worry too much about them at this point.

  4. You now need to create a source file so that you have a place to type in the C++ program we develop as a class:
    • Select New from the File menu.
    • In the New dialog box, select the Files tab (it may be selected already).
    • Select C++ Source File (or C/C++ Header File, if you are creating a ".h" file) in the Type list.
    • Make sure the Add to project: box is checked, and that your project name is listed below it.
    • Type the name of your file in the File name box, making sure that the Location field is correct (e.g., c:\My Documents\CS100\lab1).
    • Click the OK button.
    • A window will appear in which you may type your source code and then Save it.

    If you already had an existing source file you could avoid retyping it by including it in the project. The follow procedure can be used to add and existing source file to a project:

    • On the Project menu, select Add to project->Files ...; in the Insert Files into Project dialog, select the hobo.cpp source file from the list (it should be the only file listed) and then click on the OK button.
    • To view or edit your source file, select Open on the File menu, select your source file again, and click on the Open button. (Another way to open your file is to double-click on its name in the FileView list on the left side of the screen, but that's a little more complicated.)
  5. There are several other ways to do this, so ask the instructor if you are having any difficulty.

    In the future, when you modify your program, be sure to open the existing project by selecting Open Workspace ... from the File menu.

  6. Now type in the source code that we developed in lab.
  7. Next build the project. On the Build menu, select Rebuild All. If you get errors you don't understand, it is possible that your compiler options (e.g., file directories and library selection) are not set properly. Consult the instructor for assistance.
  8. Select the Execute program icon or press Ctrl+F5. (If you want to debug, select the Go icon or press F5). Your program should run. The console window may close at the end of the program before you can see the output.
  9. Test the program by running it to see if it produces reasonable values. (Of course, this is not a complete test.)
  10. Consider the following questions:
    • What could be done to provide a more complete test of your program?
    • Suppose that the numbers in our problem ($10,000, 6%, and $500) could be selected by the user. Are there values for which the program would not terminate? What changes would be need to be made to ensure that the program always terminates?
  11. Submit the lab report (details below).

Lab report (due 4:30pm Tuesday, September 21, 1999)

The lab report should consist of the following:

  • A copy of the source code.
  • A description of the approach your group used to define an algorithm (in English).
  • Answers to the questions in step 9.
  • A brief description of any problems you encountered or questions you have regarding the lab.
  • Any ideas you have for how the lab assignment could be improved in the future.

As with any report you submit, correct spelling and grammar are required. In addition, your report should be submitted electronically following the Electronic Submission Guidelines. (You may wish to consult the sample report before submitting your report.) Be sure to keep copies of all your files, in case something gets lost. It may be wise to keep a diskette backup as well.

If you have any questions, consult the instructor.


This page copyright 1999 by Dr. Christopher C. Taylor