Advertisement
Guest User

my life

a guest
Oct 16th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. Time it took Matthew to complete: 40 minutes
  2. Files to submit: conversions.c
  3.  
  4. Requriements
  5. Program must compile with both -Wall and -Werror options enabled
  6. Submit only the files requested
  7. Use doubles to store real numbers
  8. Print all doubles to 2 decimal points unless stated otherwise
  9.  
  10. Restrictions
  11. No global variables may be used
  12. Your main function may only declare variables and call other functions
  13.  
  14. Description
  15. In this program you will be converting measurements from one unit to another.
  16.  
  17. Temperatures
  18. From Farenheit Celsius Kelvin
  19. Farenheit(F) F (F - 32) * 5/9 (F-32)*5/9+273.15
  20. Celsius(C (C * 9/5) +32 C C + 273.15
  21. Kelvin(K) (K - 273.15) * 9/5 + 32 K -273.15 K
  22.  
  23. Distances
  24. From Inches Feet Yards Miles
  25. Inches(I) I I / 12 I / 36 I / 63360
  26. Feet(F) F * 12 F F / 3 F / 5280
  27. Yards(Y) Y* 36 Y * 3 Y Y / 1760
  28. Miles(M) M * 63360 M * 5280 M * 1760 M
  29.  
  30. Requirements
  31. Users should be able to enter both upper and lower case letters for units
  32. Any amount of white space should be allowed inputs
  33.  
  34. Assumptions
  35. Input is NOT guarenteed to be valid
  36. If invalid input is received, your program should report it and terminate
  37. Wait until we cover how to handle invalid input in class before dealing with this part of the problem
  38.  
  39. Tips
  40. This problem is very large and you will want to break it down into many functions to help manage complexity
  41. When reading in a character don't forget to put a space in front of the %c in scanf
  42. You can save yourself a bit of work by always converting to a common unit and then converting to the desired unit
  43. For example always converting yards first and then from yards to the desired unit
  44. The exit function in stdlib.h can be very helpful for ending a program early. If you use it make sure to do exit(0)
  45.  
  46. Examples Example 1
  47. Pick the type of conversion that you would like to do.
  48. T or t for temperature
  49. D or d for distance
  50. Enter your choice: t
  51. Enter the temperature followed by its suffix (F, C, or K): 0K
  52. Enter the new unit type (F, C, or K): C
  53. 0.00K is -273.15C
  54. Example 2
  55. Pick the type of conversion that you would like to do.
  56. T or t for temperature
  57. D or d for distance
  58. Enter your choice: d
  59. Enter the distance followed by its suffix (I,F,Y,M): 5 y
  60. Enter the new unit type (I,F,Y,M): i
  61. 5.00Y is 180.00I
  62. Example 3
  63. Pick the type of conversion that you would like to do.
  64. T or t for temperature
  65. D or d for distance
  66. Enter your choice: J
  67. Unknown conversion type J chosen. Ending program.
  68. Example 4
  69. Pick the type of conversion that you would like to do.
  70. T or t for temperature
  71. D or d for distance
  72. Enter your choice: 10
  73. Invalid formatting. Ending program.
  74. Example 5
  75. Pick the type of conversion that you would like to do.
  76. T or t for temperature
  77. D or d for distance
  78. Enter your choice: t
  79. Enter the temperature followed by its suffix (F, C, or K): 42 G
  80. G is not a valid temperature type. Ending program.
  81. Example 6
  82. Pick the type of conversion that you would like to do.
  83. T or t for temperature
  84. D or d for distance
  85. Enter your choice: t
  86. Enter the temperature followed by its suffix (F, C, or K): 420 Blaze It
  87. Invalid formatting. Ending program.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement