|
|
 |
CS-182 -- Lab 2 - Microsoft Visual C++
Winter Quarter 1998-1999
Electrical Engineering and Computer Science Department
Dr. Christopher C. Taylor
S-331, 277-7339
t a y l o r@m s o e.e d u (remove spaces)
www.msoe.edu/~taylor/
Purpose
In this lab, you will become familiar with the Build procedures for
Microsoft Visual C++ 5.0.
Overview
You will:
- Writing a program to convert from degrees Fahrenheit to degrees
Celsius (we'll do this together in lab).
- Type the program into the computer.
- Compile, build, and test the program.
- Modify the program to convert from Celsius to Fahrenheit.
- Compile, build, and test the modified program.
- Report on your results.
Procedures
- 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.
- Create a new project called
tempconv. On the
warp network, you will typically
create a directory on the f:
drive. For this lab, use the subdirectory
f:\tempconv.
- 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 f:\
in the Location field. Do
this first, before entering a name in the Project
name field.
- Enter tempconv 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 f:\tempconv, 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.
This will create a new project called
tempconv in the directory
f:\tempconv.
If you look in this directory, you will see several files with names that
begin with the project name (here, tempconv), but don't worry
too much about them at this point.
- Create a new source file and type in your program.
- 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.,
f:\tempconv).
- Click the OK button.
- In the resulting text window, type your source code and then select
Save.
For future reference, if you already had an existing source file, you should:
- On the Project menu, select Add to
project->Files ...; in the Insert Files into
Project dialog, select the tempconv.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.)
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.
- 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.
- 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. (Usually this happens if you selected
Go instead of Execute program.) There
are at least two ways to work around this:
- Add an extra input statement (e.g., "cin >>
intVar") at the end of the program and then enter
a dummy value after viewing the output.
- Run the program from an MS-DOS window.
- Test the program by running it to see if it produces accurate
conversions (32 Deg F = 0 Deg C, 212 Deg F = 100 Deg C).
- Modify the program to convert from Celsius to Fahrenheit.
- Compile, build, and test the modified program.
- Answer the following questions:
- Are there any temperatures that are the same in both Fahrenheit
and Celsius? (X Deg F = X Deg C)
- If so, how many? List it/them.
- Submit the lab report (details below).
Lab report
The lab report should consist of the following:
- An overview of the lab (purpose, procedure, etc...). This should be
in your own words.
- A description of the approach you used to answer the questions in step
9 (along with the answers).
- A brief description of any problems you encountered or
questions you have regarding the lab.
- A copy of the source code for the original and modified programs. (Be
sure to follow the
documentation standards
that I have set for all programs you write for this class.)
- Example input/output combinations for the two programs you wrote.
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.
The lab report is due at 4:00pm the day prior to the following lab period
(4:00pm, Monday, Dec. 8, 1998), though you are encouraged to submit it sooner
if you can. If you have any questions, consult the instructor.
This page was created by Dr.
Christopher C. Taylor and is based heavily on material developed by
Dr. Mark J. Sebern.
|