Perl Programming/Exercise 5

Temperature Converter
Write a program that takes in a temperature (either Celsius or Fahrenheit) and converts it. The program will know what to convert it to through interpreting the last character in the input string, which will either be an 'F' (for Fahrenheit) or a 'C' (for Celsius). So, for example if the user were to input 10C, the program will output 50F (the output should be to the nearest whole integer). If the end character in the input string is not equivalent to an F or a C, the program should handle the error appropriately.

For extra points, have the program print out its opinion on the temperature. For example, if the user were to input 50F, the program would say "10C, that's cold!".

Answers

Previous exercise | Next exercise