시작하기무료로 시작하기

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.

이 연습은 강의의 일부입니다

Introduction to Bash Scripting

강의 보기

실습형 인터랙티브 연습문제

이론을 실습으로 바꾸는 인터랙티브 연습 중 하나를 만나보세요

연습 시작