COMP 141: Project 2
The Perfect Storm
In this project, you will write a program to calculate information about tropical cyclones.
These storms are known by different names: they are called hurricanes
in the Atlantic Ocean and northeastern Pacific Ocean, and typhoons when
they occur in the northwestern Pacific Ocean.
Hurricanes and typhoons are classified into categories based on the sustained speed of
the winds inside the storm. For hurricanes, the speeds are classified on the
Saffir–Simpson scale: (notice these are in miles per hour)
Hurricanes |
Type | Wind speed |
Tropical depression | under 39 mph |
Tropical storm | at least 39 mph, but less than 74 mph |
Category 1 | at least 74 mph, but less than 96 mph |
Category 2 | at least 96 mph, but less than 111 mph |
Category 3 | at least 111 mph, but less than 130 mph |
Category 4 | at least 130 mph, but less than 157 mph |
Category 5 | 157 mph or higher |
For typhoons, one classification system is the
following: (notice these are in kilometers per hour)
Typhoons |
Type | Wind speed |
Tropical depression | under 63 km/hr |
Tropical storm | at least 63 km/hr, but less than 88 km/hr |
Severe tropical storm | at least 88 km/hr, but less than 118 km/hr |
Typhoon | at least 118 km/hr, but less than 150 km/hr |
Severe typhoon | at least 150 km/hr, but less than 185 km/hr |
Super typhoon | 185 km/hr or higher |
In this program, you will have a user type in a wind speed in either miles per hour or
kilometers per hour, and classify that storm on both the hurricane and typhoon scales.
What you need to do
Your program, when completed, should do the following:
- Ask the user whether they want to type in a wind speed in miles per hour or kilometers per hour. The user should be able to
enter either "k" or "K" for kilometers, and either "m" or "M" for miles. They only need to type the single letter. You may allow the user
to type the whole word if you so desire.
- Print out the wind speed in using the opposite units (so the user can see the speed in both mph and km/hr).
- Print out the hurricane category.
- Separately, print out the typhoon category.
Guidelines
- Follow the instructions for commenting your code.
- Use the following to convert back and forth between kilometers per hour and miles per hour:
one kilometer per hour = 0.621371 miles per hour.
- You should use a series of if-elif-else tests for the hurricane and typhoon scales.
For your if-elif-else statements, do your hurricane tests in miles per hour and your typhoon tests
in kilometers per hour.
- You may assume the user will always type integers. However, the conversion to the other unit of measurement
will almost certainly result in a decimal number.
Submission
- Your program should be named cyclone_yourLastName_yourFirstName.py
- Submit your Python file on Moodle under Project 2.
Sample Interactions
What the computer displays (prints) is in regular text, what the user types is in bold, and what
the program is doing behind the scenes is in italics.
Test 1
(Program begins)
Do you want to enter miles/hour or km/hour? (type m or k): m
What is the speed of the hurricane in miles/hour? 150
This is 241.4016746838845 km/hr.
On the hurricane scale, this is a category 4 hurricane.
On the typhoon scale, this is a super typhoon.
(Program ends)
Test 2
(Program begins)
Do you want to enter miles/hour or km/hour? (type m or k): k
What is the speed of the hurricane in km/hour? 150
This is 93.20565 mph.
On the hurricane scale, this is a category 1 hurricane.
On the typhoon scale, this is a severe typhoon.
(Program ends)
Test 3
(Program begins)
Do you want to enter miles/hour or km/hour? (type m or k): M
What is the speed of the hurricane in miles/hour? 55
This is 88.51394738409098 km/hr.
On the hurricane scale, this is a tropical storm.
On the typhoon scale, this is a severe tropical storm.
(Program ends)
Your code does not need to follow this script verbatim, but all the mentioned functionality
should work as shown.
Requirements
A good program will do all of the following:
Be named correctly.
Include the standard program header as a comment at the top of your program.
Ask the user for all input using clear and understandable prompts.
Display all information using clear and understandable messages.
Using appropriate variable naming conventions.
Include code that is commented appropriately, is neatly and clearly formatted, and includes proper use of white space.
Hints
- Work out some examples on paper first to determine how the math works in this problem.
- Decide on what variables you need, what they represent in the problem, and what their data types should be.
Test your program on lots of examples and make sure the math checks out.
Challenge Problems
- Include another intensity scale, such as the one used in Australia, the Indian Ocean, or the Beaufort scale.
- Let the user pick which scale they want to see (so instead of printing the category for every scale, let the user
pick which one they want to see).
Grading
Your program will be graded on correctness (whether your calculations are correct), as well as on coding style,
which refers to choices you make when writing your code, such as good use of variable names, appropriate indentation,
and comments (this is not an exhaustive list).
You will receive one bonus point for every complete day your program is turned in early, up to a maximum of five points.
For instance, if your program is due on September 20 at 11:59pm, if you turn in your code on Moodle any time
on September 19 from 12:00am through 11:59pm, you will receive one extra point on your project.
Programs submitted on September 18 from 12:00am through 11:59pm will receive two points. This pattern continues
for up to five points.