This program will take the user\'s input as a temperature in degrees Fahrenheit.
ID: 3589310 • Letter: T
Question
This program will take the user's input as a temperature in degrees Fahrenheit. The user will then click a radio button indicating whether a table of temperatures, starting with the entered value, will be displayed in increments of 5 degrees F or 10 degrees F. When a submit button is clicked your code will display a HTML table of temperature values. The first column will be temperatures in degrees Fahrenheit, given in increments of 5 or 10 degrees F, depending on the radio button clicked. The second column of the table will be the Celsius equivalent of the Fahrenheit temperature.
degC = (degF - 32) / 1.8;
The table will include a 100 degree F range. So, if the user enters 50 and clicks the 10 degree increment radio button, the table will include 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, and 150 degrees Fahrenheit values and their Celsius equivalents. If the user enters 50 and clicks the 5 degree increment radio button, the same temperature range will be displayed for degrees F, but in increments of 5 (50, 55, 60, 65, ..., 140, 145, 150).
Temperature Conversion Table Enter a starting value in degrees Fahrenheit and an increment value. 20 Enter an value in degrees Fahrenheit. Convert in increments in 5 degrees Convert in increments in 10 degreesExplanation / Answer
For the given problem following are the PHP code to generate HTML table with the degree Fahrenheit and its equivalent degree Celcius value :
<?php
if ( isset($_POST[ 'submit' ] ) )
{
$gotValue = true ;
$degF = $_POST[ ' degF ' ];
$value = $_REQUEST['choice'];
if($value=='ten'){
$increment = 10;
}
else{
$increment = 5;
}
echo " < table border = ' 2 '> ";
echo " <tr> <td> Degree Fahrenheit </td> <td> Deegre Celcius </td> </tr> ";
for ( $deg = $degF ; $deg < ( $degF + 100) ; $deg = $deg + $increment )
{
$degC = round(( $deg - 32) / 1.8 , 1 ) ;
echo "<tr> <td> $deg </td> <td> $degC </td> </tr> ";
}
echo " </Table>";
}
else
{
$gotValue = false;
}
if(!$gotValue)
{
echo " Please enter th value first ";
}
?>
--------------------------------------------------------------------
NOTE:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.