CSCI101A

Lab Assignment #1

Week 2 Class 2

 

Before you start this lab assignment you should read ALL of this document.

 

In all labs you may work in teams of 2 people, or you may work alone.

 

Lab 1 Specification:

 

Part 1.  Go to the course web page:

 

http://www.coquitlamcollege.com/adawson/CSCI101.htm

 

Click on the link entitled "Using Borland C++ version 5.02"

 

Read and follow the instructions in the document.

 

Part 2.  Go to the course web page:

 

http://www.coquitlamcollege.com/adawson/CSCI101.htm

 

Click on the link entitled "C++ Labs"

 

Read and follow the instructions in the document.

 

Part 3. Write a program to calculate the surface area and volume of a sphere.

 

Your program should accept one number from the keyboard: the diameter of the sphere.

From this value the radius of the sphere can be determined.

 

For an example, see:

 

http://www.gomath.com/algebra/sphere.php

 

 

The input number must be a real number (includes a fractional part), so the data type for this variable will be double, not int (integer).

 

Hint: include these lines in your code:

 

double diameter, pi, surface_area, volume;

pi = 3.142;

 

The lines above declare four variables which can hold data of type double i.e. a number which includes a fractional part e.g. 1.4 or 25.241 etc. The second line assigns a value of 3.142 to pi (which represents p).

 

Test your program with the data on web page:

http://www.gomath.com/algebra/sphere.php

 

This lab is due at the end of the class (3:55pm). At 3:45pm you will be reminded to save your program file (which should be named lab1.cpp) to your folder on the network in CSCI101A\Week02\Lab1.

 

Instructions on how to locate your folder are posted on the notice board beside the door in Room 6.

 

The lab1 folder will be closed at 3:55pm precisely. Late submissions are NOT accepted.

 

To save your lab1.cpp file from the local drive to your folder in CSCI101A\Week02\Lab1,

follow the instructions in the network folder: CSCI101A\Saving

 

Please note:  Your program source code file should be named lab1.cpp and should contain appropriate comments (the file name, your name, your team partner's name if you're working in a team, the date, the program's completion status).  If you are working in a team, both

partners should save the file to their own folder. Make sure that you indent (space out) the code as recommended in the text - see example programs in the textbook for examples.

 

For more hints, see: CSCI101A\C++ Program Development

 

Your instructor is always available to answer your questions.

 

There will be a ten minute break approximately half way through the lab session.

 

AHD Wednesday 15th September 2004, 8:26 PT