Must be done in PHP. Directions are below: Please use the Assignment Five Drop B
ID: 3794887 • Letter: M
Question
Must be done in PHP. Directions are below:
Please use the Assignment Five Drop Box to submit your assignment. In this assignment use an appropriate looping statement to write a script that displays a list of the Celsius equivalents of zero degrees Fahrenheit through 100 degrees Fahrenheit in a table format. The formula to convert Fahrenheit to Celsius is: Celsius = 5/9 {Fahrenheit - 32) For this assignment you need to define a function Convert_Temp. The function should accept one argument -the degrees Fahrenheit - and will return the degrees Celsius. The function should be called from within the loop. Use the round() function which was covered in chapter one of the textbook to display the Celsius temperature to one place after the decimal point. The PHP script should display the table in the following format: Save the document as assignment_f ive .php.Explanation / Answer
<?php
function convertToCelsius($f) {
$c = 5/9*($f - 32);
return $c;
}
echo "<table><tr><th>Fahrenheit</th><th>Celsius</th></tr>";
for ($x = 0; $x <= 100; $x++) {
$celcius = convertToCelsius($x);
$celcius = round($celcius,1);
echo "<tr><td>$x</td><td>$celcius</td></tr>";
}
echo "</table>";
?>
The above code will display the information you mentioned in the table format.
The convertToCelsius($f) which i have written will convert the numbers from 0 to 100 into celcius by using the formula mentioned in the question.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.