Anne Dawson: CSCI120A_HW2_FA04.htm   

 

First created: Monday 27th September 2004, 11:49 PT

Updated:  Monday 4th October 2004, 18:34 PT

Last updated: Wednesday 6th October 2004, 13:47 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

Fall 2004

Homework 2

Specification: Weather Balloons Calculations

Step 1

 

Study the following:

 

Weather balloons are used to gather temperature and pressure data at various altitudes in the atmosphere. The balloon rises because the density of the helium gas in the balloon is less than the density of the surrounding air outside the balloon. As the balloon rises, the surrounding air becomes less dense, and thus the balloon’s ascent slows until it reaches a point of equilibrium (balance). During the day, sunlight warms the helium trapped inside the balloon, which causes the helium to expand and become less dense and the balloon to rise higher. During the night however, the helium in the balloon cools and becomes more dense, causing the balloon to descend to a lower altitude. The next day, the sun heats the helium again and the balloon rises. Over time, this process generates a set of altitude measurements that can be approximated with a polynomial equation.

 

Assume that the following polynomial represents the altitude or height in meters during the first 48 hours following the launch of a weather balloon:

 

            alt(t) = 20.12t4 + 12t3 – 380t2 + 4100t + 220,

 

where the units of t are hours. The corresponding polynomial model for the velocity in meters per hour of the weather balloon is as follows:

 

            v(t) = -0.48 t3 + 36 t2 – 760t + 4100

 

Print a table of the altitude and the velocity for this weather balloon using units of meters and meters/second. Let the user enter the start time, increment in time between lines of the table, and ending time, where all the time values must be less than 48 hours. In addition to printing the table, also print the peak altitude and its corresponding time.

 

Example:  Assume that the starting time is 0 hours, the time increment is 1 hour, and the ending time is 5 hours. To obtain the correct units, we need to divide the velocity value in metres/hour by 3600 in order to get metres/second.  Using a calculator, we can then compute the following values:

 

Time        Altitude (m)    Velocity (m/s)

    0           220.00        1.14

    1          3972.12        0.94

    2          7317.92        0.76

    3         11053.72        0.59

    4         16458.72        0.45

    5         25295.00        0.32

 

 

We can also determine the maximum altitude for this table, which is 25295.00 metres which occurred at 5 hours.

 

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

 

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

 

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:    Weather Balloon Calculations

#  Programmer: [your name]   

#  Course:     CSCI120A

#  Date:      

#  Test data:

 

 

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\Week06\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.