## CS 115 Program 1 Windchill Calculation Spring 2018

Due Dates:
Individual Design: Wednesday, February 14, midnight
Individual Source: Sunday, February 25, midnight

Assignment total points = Design (20 points) + Runs given test cases successfully (20 points) + Implementation correctly written (70 points) + Style and documentation (15 points) = 125 points

#### Submit your work with the link here. Use Program 1 and Design for the design, Program 1 and Code for source code.

Note that there is a FAQ about program 1. Please read this! It will save you points!

Note about collaboration: As stated in the syllabus and the first day of class, you are allowed to choose ONE other student from this class and work with them as a partner. The other student may NOT have already worked with someone else in the class. Pairs are allowed, not chains nor networks! And choose partners BEFORE the due date. You do not want to make your partner late too! You must reference your partner AND they must reference you in submitted work. All program source code and designs will be checked for similarity. If similarity is found and no references are given, it will be investigated for plagiarism.

Educational Goals: The educational goals of this program are that the student should use the concepts of

• design using pseudocode
• output of prompts and labels to match specified output
• input of values from the keyboard
• translating algebraic equations into Python expressions
• using math library functions
• calculations in assignment statements
• documentation
• testing with valid inputs and invalid inputs

The wind makes us colder when it blows across the exposed area of our skin. It draws heat away from out bodies. When the wind speeds up, it draws more heat away, so your body cools faster than if it were a still day. A couple Antarctic explorers in the 40's (Siple and Passel) experimented with water bottles and different wind conditions. They formed the first formula to express windchill. There have been some changes in the formula over the years because windchill is a difficult measurement to express. How many factors should it take into account? the humidity? the person's size and weight? day or night? latitude?

Here are the formulas you need:

where velocity is the wind speed in miles per hour and tempF is the Fahrenheit temperature.

• The first formula is to calculate the windchill according to an older formula, used up until 2001.
• The second formula calculates the windchill according to the current formula.

Your program should develop a table of windchills, based on the user's inputs of the temperature and the starting wind speed. The table should produce columns as seen below: wind speed, the windchill according to the new formula, windchill according to the old formula and the difference between the two windchills. The table should be nicely labeled. Some suggestions for formatting are given below. The column of wind speeds should start at the value the user gives. Set the range to stop at 90 mph. The step size is set at 5.

Sample Run:

```Big Blue Chill

Starting Wind Speed (in miles per hour): 1
Air temperature (in F degrees): 15
Speed cannot be 3 or below.  4 mph used instead

Temperature 15.0 F

Windspeed       New Formula     Old Formula     Difference

4            8.44            15.7            -7.3
9            3.37           0.492             2.9
14           0.311            -8.8             9.1
19           -1.93           -15.2            13.3
24           -3.72           -19.9            16.2
29           -5.22           -23.3            18.1
34           -6.51           -25.8            19.3
39           -7.66           -27.6            19.9
44           -8.69           -28.8            20.1
49           -9.62           -29.5            19.9
54           -10.5           -29.7            19.2
59           -11.3           -29.6            18.3
64           -12.0           -29.2            17.2
69           -12.7           -28.5            15.8
74           -13.3           -27.6            14.3
79           -14.0           -26.4            12.4
84           -14.5           -25.0            10.5
89           -15.1           -23.5             8.4
```

Another Sample Run:

```Big Blue Chill

Starting Wind Speed (in miles per hour): 10
Air temperature (in F degrees): -20

Temperature -20.0 F

Windspeed       New Formula     Old Formula     Difference

10           -40.7           -44.3             3.6
15           -45.0           -56.8            11.8
20           -48.2           -65.6            17.4
25           -50.8           -72.0            21.2
30           -53.0           -76.7            23.7
35           -54.9           -80.1            25.2
40           -56.6           -82.5            25.9
45           -58.1           -84.1            26.0
50           -59.5           -85.0            25.5
55           -60.8           -85.2            24.4
60           -62.0           -85.0            23.0
65           -63.1           -84.3            21.2
70           -64.1           -83.2            19.1
75           -65.1           -81.8            16.7
80           -66.0           -80.0            14.0
85           -66.9           -77.9            11.0
```

Make sure you format the lines of the output as described above. Line breaks, spacing, spelling should be very similar to the sample runs.

## Testing

These test cases will be used to test your program when the TAs are grading. It's only wise to make sure that your program runs these successfully. The example runs above also are used as test cases.

The numbers given here are representing the numbers in the first row of the table generated by the inputs shown.
Description of CasesInputs Expected Outputs / Actions
Wind SpeedTemperatureNew formulaOld formula DifferenceAction
1. Normal speed (number > 3) and temperature (number <= 50) 8 35 28.526.1 2.4
2. Boundary speed and normal temperature 4 30 25.830.6-4.8
3. Boundary speed and float temperature 4 25.520.626.1 -5.5
4. Boundary speed and very low temperature 4 -100-124.4 -98.2 -26.2
5. Speed past bound of table, normal temperature 95 10 Table has only headers, no data
6. Speed below the boundary, normal temperature 0 10 2.7 10.8-8.1 set speed to 4 mph
7. Normal speed, negative temperature 10 -10 -28.3 -32.13.8
8. Normal speed and temperature past upper bound 30 75 42.028.913.1 temp set to 50 degrees
9. Normal speed and temperature at upper bound 20 50 43.633.010.6

This NOAA site has a windchill calculator for the new formula, where you can check your calculations. It's always better to have an independent way of checking your work. Do some research - read the NOAA government site to find out for what ranges the formulas are supposed to be defined.

## Design

Make a list of steps to solve this problem and put it in Python comment form. Save this Python file as "design1.py".
```# supply program prolog  - fill this in! personal info, 3 P's, references
#  main function
# Display introductory message
# (some of your design here)
# loop for the range of windspeeds desired with stepsize of 5
#     Calculate the windchill for the current windspeed using the old formula
#     (more design goes here)
#     Output the windspeed, the new windchill, the old windchill and the difference
#     (more design goes here)
```
and fill in the missing steps in the design.

There are some specifications that your program needs to meet.

• This program uses user inputs; you will have to prompt the user for them.
• You MUST use assignment statements to do your calculations, not calculating expressions in output statements.
• You MUST use at least one math library function. Yes, there is a way to write the equation without using math functions (the ** operator), but the specification is to use a math library function.
• You must look up the limits of ranges on the formulas and enforce those in your program. For example, the windspeed must be more than 3 miles per hour. See the reference link below for the source of these restrictions.
• If the user gives a starting windspeed higher than 90 mph, then there will be no lines of data output. This is normal action for a for loop. Your program does not have to do anything extra to enforce this.
• Note the types of data being output. Your program must match those.
• Note the decimal places shown. Use the round function as needed. The numbers from the formulas and the difference are rounded to 1 place.
• Use this line to output the results in your table:
` print(" {:15} {:15.3} {:15.3} {:15.3}".format(wspeed, new, old, diff))`

This gives each variable 15 columns on the screen, and uses 3 of them to display the value, including decimals.
• Your code must be documented. You must use meaningful variable names. You must have a prolog. Your design must appear in between the Python statements.