Anne Dawson: CSCI120A_HW2_SP05.htm   

 

Last updated: Monday 24th January 2005, 6:48 PT

 

This document is subject to change without notice.

 

Please report any errors or omissions in this document:

adawson@coquitlamcollege.com

 

Special instructions:  For this assignment you must work alone.

See schedule for due date.

 

 

CSCI120A

 

Introduction to Computer Science and Programming

Spring 2005

Homework 2

Calculation of the volume and surface area of a sphere and cylinder

Step 1

 

Go onto the Internet to find the formulae to calculate the volume and surface area of a sphere and a cylinder. For calculations involving a sphere, the user must input the radius. For calculations involving a cylinder, the user must input the radius and height. Use units of centimetres for all your measurements.

 

 

Step 2

 

Design an algorithm (the steps to solve the problem). The following web page will help you design your algorithm and pseudocode:

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

You should type your algorithm in comments at the top of your source code in hw2.py.

 

 

Step 3

 

Development the pseudocode from your algorithm.

The following web page will help you design your algorithm and pseudocode:

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

You should type your pseudocode in comments at the top of your source code in hw2.py.

 

 

Step 4

 

Using your pseudocode as a guide, implement your program in the Python language. Use the IDLE GUI to edit and run your program:

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

 

Your program should start with a comment block that contains the following information:

 

#  File:       HW2.py

#  Purpose:    Volume and Surface Area of a Sphere and Cylinder

#  Programmer: [your name]

#  Course:     CSCI120A

#  Date: 

 

#  Algorithm:    

 

#  Pseudocode:

 

#  Test data:

 

Your program should first ask the user for the radius (in cm) of the sphere, then outputs the volume and surface area of the sphere. Your program should then ask the user for the radius and height (in cm) of the cylinder, then outputs the volume and surface area of the cylinder. Your program then asks the user if they want to run the program again, and the program repeats as long as the user enters "yes" or "y" regardless of case.

 

 

Step 5

 

Test your program by running supplying your own test data. You should test your program with at least 3 sets of test data. Show your test data and results in comments at the top of your program.

 

Step 6

 

When due, save your program file (HW2.py) to your folder on the network in:

 

CSCI120A\Week05\HW2

 

 

Program points will be based on the following marking scheme:

 

Marking Scheme

Category

Points

Description

Algorithm

10

An informal description of the steps that must be taken to solve the problem.

ref: http://www.coquitlamcollege.com/adawson/Pseudocode.htm

Pseudocode

10

A formal description of the steps that must be taken to solve the problem.

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

Comments

10

The program should be commented as specified in this document.

Style

10

The source code should use meaningful variable names (identifiers).

Output

15

Screen prompts and results should be user-friendly.

Correctness

15

The program should output correct results.

Completeness

15

The program should be complete.

Test

15

Comments in the code explain how the code was tested.