Using Floating Point Math and printf
For some strange reason, you’ve found yourself working a job that requires you to keep track of weather-related statistics. Your boss has just sent you a text file that contains a list of temperatures. Some of the temperatures are Celsius temperatures, and some are Fahrenheit temperatures. Your assigned task is to convert the Fahrenheit temperatures to Celsius temperatures. You can do that the hard way by using a calculator to manually convert each Fahrenheit temperature, or you can write a script that will automate the process. You’ve decided that it would be easier to write a script. The list of temperatures is in the temps.txt
file, which looks like this:
Temperature Celsius_or_Fahrenheit
32 F
212 F
-40 F
-14.7 F
24.6111 C
75.8 F
55.21 F
23.9444 C
29.8 F
104.34 F
98.6 F
23.1 C
The first three temperatures are checks to verify that the script works correctly. We know that 32 degrees F equals 0 degrees C, that 212 degrees...