Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. /*******************************************************************************
  2. AUTHOR SECTION
  3.  
  4. ENGR 200.06 DATE: 02/12/2017
  5.  
  6. PROGRAM: #3 Author: Kevin Davis
  7. ********************************************************************************
  8. PROGRAM DESCRIPTION
  9. This program will calculate windchill and time to frostbite.
  10.  
  11. DESCRIPTION OF VARIABLES
  12. NAME | TYPE | DESCRIPTION
  13. Chill | double | Wind Chill (Output)
  14. Frostbite | double | Time to frostbite (Output)
  15. Fahrenheit | double | Input temperature in degrees fahrenheit
  16. Wind | double | Input wind speed in miles per hour
  17. -----------------------------------------------------------------------------
  18.  
  19. *******************************************************************************/
  20.  
  21. /* Preprocessor directives */
  22. #include <stdio.h>
  23. #include <math.h>
  24.  
  25. /* Main function */
  26. int main()
  27. {
  28. /* Declare variables */
  29. double Fahrenheit = 0;
  30. double Wind = 0;
  31. double Chill = 0;
  32. double Frostbite = 0;
  33.  
  34. /* Input values */
  35. printf("********************************************\n");
  36. printf(" WIND CHILL CALCULATION \n\n");
  37. printf("Enter temperature in degrees Fahrenheit:");
  38. scanf("%lf", &Fahrenheit);
  39. printf("Enter wind speed in miles per hour :");
  40. scanf("%lf", &Wind);
  41.  
  42. /* Compute Wind Chill */
  43. if (-45 <= Fahrenheit && 40>= Fahrenheit)
  44. {
  45. Chill = 35.74+(0.6215*Fahrenheit)-35.75*pow(Wind, 0.16)+0.4275*Fahrenheit*pow(Wind, 0.16);
  46. }
  47. else
  48. {
  49. printf("error! recheck input for temperature");
  50. return 0;
  51. }
  52. if(0 <= Wind && 60 >= Wind)
  53. {
  54. }else {
  55. printf("error! recheck input for wind speed");
  56. return 0;
  57. }
  58.  
  59. if (Chill >= -35 && Chill <= -18)
  60. {
  61. Frostbite = 30;
  62. }
  63. else if (Chill >= -55 && Chill <= -36)
  64. {
  65. Frostbite = 10;
  66. }
  67. else if (Chill > -56)
  68. {
  69. Frostbite = 5;
  70. }
  71. else
  72. {
  73. printf("No frostbite concerns expected.");
  74. }
  75. /* Print output values */
  76. printf("\nRESULTS\n");
  77. printf("Temperature (degrees F): = %3.1f \n", Fahrenheit);
  78. printf("Wind speed (miles/hour): = %2.1f \n\n", Wind);
  79. printf("Wind Chill = %3.1f \n", Chill);
  80. printf("\nTIME TO FROSTBITE = %02d minutes \n", Frostbite);
  81. printf("********************************************\n");
  82.  
  83. /* Exit the program */
  84. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement