C Programming

====

This assignment requires you to write functions to produce weather tables. It also uses a do-while loop and nested for loops, along with the math library. Your program will ask the user for inputs, then produce a weather table, repeatedly until the user is finished. Use functions to isolate the logical steps of the task, including the weather calculations themselves. You should also use functions to flush excess input from stdin, and to print standardized lines around your tables. Submit your source file. Remember to include a comment with your name, assignment number and description, and date. Program behavior An example run of the instructor's program is at the bottom of this writeup. Yours doesn't have to look identical, but it should look very similar to this. Your program should use a do-while loop to repeatedly ask for a table choice. The user enters a 'w' for a windchill table, a 'h' for a heat index table, or 'q' to quit the program. Having determined which table to produce, ask for the temperature range (minimum and maximum) in degrees Fahrenheit; these values should be of type float or double. Also get either the wind-speed range (for the windchill table) or the relative-humidity range (for the heat-index table); these values should be integers. Use nested for loops to create a table of perceived temperatures for each combination of temperature and wind or humidity. Whether heat index or windchill, the output table must contain 11 rows and 6 columns. This can be done by computing step sizes of (maximum-temperature - minimum-temperature)/10 for the outer for loop; and (max.-humidity-or-wind - min.-humidity-or-wind)/5 for the inner loop. Heat Index calculation A detailed description of the heat index is available from this NOAA webpage. A regression equation for calculating the heat index is: Heat Index = -42.379 + (2.04901523 × Temp ) + (10.14333127 × RH ) - (0.22475541 × Temp × RH ) - (0.00683783 × Temp 2 ) - (0.05481717 × RH 2 ) + (0.00122874 × Temp 2 × RH ) + (0.00085282 × Temp × RH 2 ) - (0.00000199 × Temp 2 × RH 2 ) This formula is considered valid for heat-index values above 80 degrees F, with an error of ±1.3 degrees F. You can use the pow() function to calculate the squares (2nd power) of Temp and RH. pow() is available in the header file. You will also need to link in the math library by using the -lm flag, like this: gcc -Wall -o myprog myprog.c -lm Another way to write the heat index expression is to use exponential notation for the constants, like this:

Heat Index = -42.379 + (2.04901523 × Temp ) + (10.14333127 × RH ) - (0.22475541 × Temp × RH ) - (6.83783e-3 × Temp 2 ) - (5.481717e-2 × RH 2 ) + (1.22874e-3 × Temp 2 × RH ) + (8.5282e-4 × Temp × RH 2 ) - (1.99e-6 × Temp 2 × RH 2 ) Exponential notation is useful for very large and very small numbers, and C is happy with it. Wind Chill calculation A detailed description of wind chill is available from this NOAA webpage. The formula for calculating wind chill is:

WindChill = 35.74 + (0.6215 × Temp ) - (35.75 × Wind 0.16 ) + (0.4275 × Temp × Wind 0.16 ) The windchill calculation is considered valid for wind speeds between 3 mph and 60 mph, and temperatures between -45 degrees F and +45 degrees F. Note that you must take a non-integer power of the wind speed. To do this, you need the pow() function, available in the header file. You will also need to link in the math library by using the -lm flag, like this: gcc -Wall -o myprog myprog.c -lm Example run 507] ./weather-tables heat index, wind chill, or quit? w w... temperature range: -10 30 windspeed range: 4 25 T \ W 4.0 8.2 12.4 16.6 20.8 25.0 ----- ----- ----- ----- ----- ----- ----- -10.0 -20.4 -26.3 -30.0 -32.8 -35.1 -37.0 -6.0 -15.8 -21.4 -25.0 -27.7 -29.9 -31.7 -2.0 -11.2 -16.6 -20.0 -22.5 -24.6 -26.4 2.0 -6.6 -11.7 -14.9 -17.4 -19.4 -21.0 6.0 -2.0 -6.8 -9.9 -12.2 -14.1 -15.7 10.0 2.7 -1.9 -4.9 -7.1 -8.9 -10.4 14.0 7.3 2.9 0.1 -1.9 -3.6 -5.1 18.0 11.9 7.8 5.2 3.2 1.6 0.3 22.0 16.5 12.7 10.2 8.4 6.9 5.6 26.0 21.1 17.5 15.2 13.5 12.1 10.9 30.0 25.8 22.4 20.3 18.7 17.4 16.3 ----- ----- ----- ----- ----- ----- ----- heat index, wind chill, or quit? x x... Unrecognized choice heat index, wind chill, or quit? h h... temperature range: 80 110 humidity range: 60 95 T \ H 60.0 67.0 74.0 81.0 88.0 95.0 ----- ----- ----- ----- ----- ----- ----- 80.0 81.8 82.6 83.4 84.4 85.3 86.4 83.0 85.9 87.6 89.5 91.6 94.0 96.5 86.0 91.1 93.8 96.9 100.3 104.1 108.3 89.0 97.4 101.2 105.6 110.4 115.8 121.8 92.0 104.7 109.8 115.6 122.0 129.1 136.9 95.0 113.1 119.6 126.9 135.0 143.9 153.6 98.0 122.6 130.6 139.5 149.4 160.3 172.0 101.0 133.1 142.8 153.5 165.3 178.2 192.1 104.0 144.8 156.2 168.8 182.6 197.6 213.8 107.0 157.5 170.7 185.3 201.3 218.6 237.2 110.0 171.2 186.5 203.3 221.5 241.1 262.2 ----- ----- ----- ----- ----- ----- ----- heat index, wind chill, or quit? q

Answer :

The program requires writing functions to produce weather tables, including wind chill and heat index calculations. It uses a do-while loop and nested for loops to repeatedly ask the user for inputs and generate the corresponding weather table. The program utilizes mathematical formulas and the math library in C.

The program starts by asking the user for a table choice: 'w' for wind chill, 'h' for heat index, or 'q' to quit the program.

If the user chooses 'w' for wind chill, the program prompts for the temperature range (minimum and maximum) in degrees Fahrenheit and the wind speed range.

Using nested for loops, the program generates a table of perceived temperatures (wind chill) for each combination of temperature and wind speed. It creates an 11-row by 6-column table.

If the user chooses 'h' for heat index, the program asks for the temperature range (minimum and maximum) in degrees Fahrenheit and the relative humidity range.

Using nested for loops, the program calculates the heat index for each combination of temperature and relative humidity. It generates an 11-row by 6-column table.

The program uses the provided mathematical formulas to compute the wind chill and heat index values.

The math library function pow() is used to calculate exponential powers of temperature and humidity or wind speed.

The program prints the generated weather table, including the temperature and corresponding wind chill or heat index values.

The program continues to prompt the user for table choices until the user enters 'q' to quit.

The program utilizes functions to isolate the logical steps of generating weather tables, including wind chill and heat index calculations. It uses a do-while loop to repeatedly ask the user for inputs and generates the corresponding tables using nested for loops. The math library is used for mathematical calculations, and the pow() function calculates exponential powers. The program provides a user-friendly interface to choose between wind chill and heat index tables and allows the user to input temperature and either wind speed or relative humidity ranges.

To know more about math library in C visit

https://brainly.com/question/29991763

#SPJ11