Assignment (6)

CS1440 Due October 16, 2001

 

1.

Write a C++ program to compute the wind-chill using two different models given below. Your program should be able to compute the wind-chill for a single case as well for an entire given month when the data for that month is provided in a file. I will provide you two files containing the data for last October and November. Your code will have the following three options:

 

1)     Run the program for a single case: make the choice for unit combination (Celsius-m/s OR Fahrenheit-mph), ask for one s and one t and compute WC, then exit. Where s is the wind speed and t is the temperature.

2)     Run the program for an input file: make the choice for unit combination, ask for an input file name, ask for an output file name, perform computations, write the output file, exit)

3)     Quit

If the user chooses option (1) or (2), then the user has to decide which model he/she would like to use to compute the wind-chill. Here are the two models when unit combination is Celsius-m/s, i.e., temperature is in degree Celsius and wind speed is in m/s:

 

Siple:

Court:

 

Where, s >= 1.79 m/s and t < 33 degree Celsius. These are also your constraints and you need to make sure the program displays message for t and s values that are not meeting these constraints.

 

If you use Fahrenheit for t and mph for wind speed, s, then you will have these two for your model:

 

Siple:

Court:

 

Where, s >= 4 mph and t < 91.4 degree Fahrenheit. These are your constraints too.

 

Test your code for some cases that you have computed by hand. Here is an example:

S = 20 mph, t = 20 F, WC = -10.5 F.

 

You can use the data at: http://www.atd.ucar.edu/homes/rilling/wc_table.html

To confirm your answers.

 

You are to use several functions in your program. You can use as many functions as you wish, some of the functions that are desired are listed below:

 

1)     A function that describes the program

2)     A functions that get the choices: 1) single calculation, 2) read from file, 3) quit. This function also asks users to choose an integer as the number of decimal points (precisions) that they wish to represent their calculations.

3)     A function that asks users for the input and output file names if choice (2) was selected in the previous step. This function will return the input and output streams to the main.

4)     A function that asks what combination of units are desired: 1) for Celsius m/s, 2) for Fahrenheit-mph, all others are invalid. Prompt the user to select the correct combination.

5)     A function that returns what model is desired for calculation based on the unit combination made previously: 1) Siple, 2) Court, all others are invalid. Prompt users until the right choice is made. Actually there are four possibilities. 1) Siple (Celsius-m/s), 2) Court (Celsius-m/s), 3) Siple (Fahrenheit-mph), and 4) Court (Fahrenheit-mph).

6)     Four functions that will compute the wind-chill based on the four given models above.

7)     A function that takes care of printing the output. This function should print the output into an output file when the program is reading the input from a file (option 2 at the beginning). It has to have a parameter for the number of decimal points used for writing the output.

 

You will use the submit command to submit your code to the directory assgn6. A hardcopy is due on the next day.


 

October 2000 Data

 

Day

Temperature (F)

Wind Speed (mph)

 

 

 

1

48.3

9.0

2

45.7

14.0

3

54.9

19.0

4

55.7

14.0

5

54.9

11.0

6

50.2

27.0

7

34.7

20.0

8

30.8

22.0

9

28.7

30.0

10

31.9

24.0

11

35.8

15.0

12

41.5

9.0

13

44.5

11.0

14

47.7

14.0

15

47.9

8.0

16

49.5

8.0

17

51.0

13.0

18

49.9

24.0

19

40.6

15.0

20

43.5

12.0

21

50.4

13.0

22

51.1

10.0

23

46.9

11.0

24

45.9

14.0

25

52.2

7.0

26

49.5

7.0

27

46.6

23.0

28

48.2

29.0

29

36.6

17.0

30

41.1

17.0

31

42.7

18.0

 


 

November 2000 Data

 

Day

Temperature (F)

Wind Speed (mph)

 

 

 

1

46.1

14.0

2

50.1

16.0

3

53.6

19.0

4

47.3

15.0

5

37.0

18.0

6

33.6

14.0

7

45.1

21.0

8

53.2

16.0

9

47.0

36.0

10

31.1

37.0

11

29.0

30.0

12

33.8

9.0

13

38.8

14.0

14

27.0

29.0

15

26.0

29.0

16

29.9

18.0

17

24.2

28.0

18

21.0

22.0

19

24.2

14.0

20

22.6

32.0

21

15.4

30.0

22

14.6

35.0

23

28.8

20.0

24

30.0

9.0

25

29.1

21.0

26

36.1

27.0

27

32.7

33.0

28

33.8

20.0

29

33.8

31.0

30

26.1

31.0