COMP 1105 – Computer Programming I Semester 1 2004-5
1
Assignment 2 (10 %)
Weather Prediction System
Early detection of hazardous conditions, such as hurricanes (as you might have
experienced recently) is important to save lives and property. Using a simplified version
of the formulas typically used, the aim of this assignment is to develop a weather
prediction system.
System Requirements:
You are required to develop a system that given the required data (see Tables 1 and 2
on page 3), it allows the user to perform the following tasks:
(1) Predict the maximum and minimum temperatures
(2) Predict the amount of rainfall
(3) Provide a hurricane advisory service
Tasks Specification:
(1) Predict maximum and minimum temperatures
Your program should accept from the user 10 Temperature readings, (in degrees
Celsius) one Clouds reading, one dew point reading (in degrees Celsius) and one
relative Humidity (RH) reading (in %) for a weekday and compute the values of the
Maximum and Minimum temperatures for the next day.
Use the following formula and conditions for your computations:
Minimum Temperature for the next Day
0.35 t)/2] [( + + = DewPoin rature ximumTempe WeekDay_Ma rature nimumTempe NextDay_Mi
IF Clouds reading is greater than 4 THEN
Add 1 to Computed value for NextDay_MinimumTemperature
ELSE
Value of NextDay_MinimumTemperature remains as computed
Note: The value of DewPoint must not exceed the value of Week_Day_MaximumTemperature.
Maximum Temperature for the next Day
RH perature AverageTem Weekday rature ximumTempe NextDay_Ma * 14 . 10 _ * 0379 . 2 379 . 42 + + − =
IF (RH < 85) THEN
IF (Clouds > 4) AND (26.6 < NextDay_MaximumTemperature < 30.5) THEN
Calculate the value by which to adjust the computed value of
NextDay_MaximumTemperatureusing:
) 5 / ] _ 5 . 30 [ * ] 10 / ) 85 ([( perature AverageTem WeekDay RH Value Adjustment − − =
ELSE IF (Clouds < 4) AND (26.6 < NextDay_MaximumTemperature < 30.5) THEN
) 5 / ] _ 5 . 30 ([ perature AverageTem WeekDay Value Adjustment − =
ELSE
0 = Value Adjustment
Calculate Final Value of NextDay_MaximumTemperature using:
Value Adjustment perature MaximumTem perature MaximumTem − = NextDay_ NextDay_
COMP 1105 – Computer Programming I Semester 1 2004-5
2
(2) Predict rainfall index
Your program should accept from the user 2 Height readings (Height1 and Height2 in
km). For each height the user should be prompted to enter a value for Temperature (in
degrees Celsius) and Wind Speed (in m/s) at that height. A single reading for Humidity
(in %) is required to predict the occurrence of rain using the following formula and
conditions:
) ] 2 1 [ * /( ) 2 1 (
* )] 2 1 ( * ) 2 1 [( *
2 Wind Wind perature MinimumTem Height Height
Height Height LapseRate e Temperatur e Temperatur Gravity ndex Rainfall_i
− −
− + − =
Notes:
• In the rainfall index equation, all temperature values must be converted to
the degrees Kelvin (See Table 1).
• In the rainfall index equation, the Minimum Temperature denotes the lower of
the two temperature values read earlier -Temperature1 and Temperature2.
• The height measurements in the final product term are the original Height1
and Height2 input values converted into meters (1 km = 1000 m).
• The lapse rate is calculated according to the following equation:
( )( ) 1 2 / 2 1 Height Height e Temperatur e Temperatur LapseRate − − =
IF Humidity > 70 THEN
IF Rainfall_index < 0.25
Display “Expect Rain Tomorrow
ELSE
Display “No Rain tomorrow but it is going to be Cloudy
ELSE
Display “No Clouds nor Rain tomorrow
(3) Provide a hurricane advisory service
Upon the user’s request for advice, your program must prompt the user for Eye Pressure
and use that value to:
a. Calculate the expected value for Maximum Wind Speed at the eye;
) Pr 3 . 101 ( * essure Eye dSpeed MaximumWin − = η
For the simplified expression (above), assume that the conversion
constant η has a value of 56. Further assume that its dimensions ensure
that the resulting speed value is measured is in km/h.
b. Issue an appropriate weather system warning (e.g. Tropical Depression
or Category 1 Hurricane) and display the approximate value of the
Storm Surge Height using the information provided in Table 2.
COMP 1105 – Computer Programming I Semester 1 2004-5
3
* To convert from degrees Celsius to degrees Kelvin add 273 to the Celsius temperature.
** Note that the value of “clouds x 10 gives the percentage of cloud coverage.
Key (Table 2): HC = Hurricane category, TD = Tropical depression (not a hurricane),
TS = Tropical Storm (not a hurricane), and S = approximate storm surge height in m.
Table 1:
Recommended Restriction of the ranges of
values entered by the user.
Table 2
Hurricane Scale
Data Range HC Maximum Wind Speed
(km/h)
S(m)
Gravity
Temperature*
Dew Point
Height
Wind Speed (Rainfall)
Humidity
Clouds**
Eye Pressure
9.8 m/s2
25 – 35 °C
19 – 26 oC
1 – 5 km
0 – 20 m/s
0 – 100 (%)
1 – 10 (weighted %)
80 – 101.1 kPa
TD
TS
1
2
3
4
5
< 61
61 – 117
118 – 153
154 – 177
178 – 209
210 – 248
> 248
-
-
1.1 – 1.7
1.8 – 2.6
2.7 – 3.8
3.9 – 5.6
> 5.6
COMP 1105 – Computer Programming I Semester 1 2004-5
4
Assignment Requirements (deliverables):
(1) An electronic copy of your program on a virus-free disk/CD
(2) A User manual.
Deadlines:
Enclose your deliverables in a clearly marked envelope with your Name, ID and Course
Code. Place the envelope inside the box provided in the General Office (CMP ground
floor) by 5 PM on Monday 15th November 2004.
General Guidelines on Deliverables:
(1) Program
a. Follow Structured Programming methodology in your program design
(Top-Down development and Modular Design).
b. Structure, Indent and Document you program source code.
c. Create an interactive and user friendly interface to your system. This
involves carefully considering the design of the interface from the user’s
perspective. Think about:
i. the design of your screens;
ii. how to perform the necessary checks on data entering your
program;
iii. the layout of your results;
iv. the messages that you wish to display to the user; and
v. how to allow the user to continue using your system for as long as
they wish to (i.e. until they choose to exit the system).
(2) User Manual
a. Indicate restrictions (or assumptions) on data that is entered into the
system.
b. Provide a set of comprehensive instructions needed to operate and use
your system.
c. Include screen shots of the user interface and a sample of the output of
the system.

Comments
Show an attempt.

Nobody is going to do your homework for you, but pasting the assignment without any of your own words is even worse.

This article has been dead for over six months. Start a new discussion instead.