Converting Fahrenheit to Celsius
You work in the analytics department for an Australian company that recently purchased an American company. The files and data from the US company are in the imperial system and need to be converted to metric. This sounds like a great opportunity to use your Bash skills to create a program which will assist.
Your task is to write a program that takes in a single number (a temperature in Fahrenheit) as an ARGV argument, converts it to Celsius and returns the new value. There may be decimal places so you will need to undertake calculations using the bc
program.
At all times use 2 decimal places using the scale
command for bc
.
The formula for Fahrenheit to Celsius is:
C = (F - 32) x (5/9)
Remember, since we are using arguments, you will need to run your script from the terminal pane rather than 'run this file' button.
Este exercício faz parte do curso
Introduction to Bash Scripting
Exercício interativo prático
Transforme a teoria em ação com um de nossos exercícios interativos
