Question

In: Computer Science

Develop a routine to convert Celcius to Fahrenheit. Have a form pass the values and a...

Develop a routine to convert Celcius to Fahrenheit. Have a form pass the values and a parm indicating what time of conversion is taking place. Use a function (if possible). Return the correct value.

Here is the formula: C = (F - 32) * 5/9

hw8.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title></head>

<body>
<p>Convert Temp</p>
<form id="form1" name="form1" method="get" action="hw8.php">
  <table width="300" border="1">
    <tr>
      <td width="122">Enter Temp </td>
      <td width="168"><label>
        <input name="temp" type="text" id="temp" size="6" maxlength="8" />
      </label></td>
    </tr>
    <tr>
      <td>Convert to &gt;&gt;&gt; </td>
      <td><p>
        <label></label>
        <label>
        <input name="type" type="radio" value="f" checked="checked" />
Fahrenheit</label>
        <br />
        <label>
        <input type="radio" name="type" value="c" />
Celcius</label>
        <br />
        <br />
      </p></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><label>
        <input type="submit" name="Submit" value="Submit" />
      </label></td>
    </tr>
  </table>
</form>
<p><a href="index.htm">return</a></p>
</body>
</html>

hw8.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<p>Temperature Conversion</p>
<p>
  You converted  Fahrenheit to 32 Celcius<br></p>
<p><a href="hw8.html">return</a></p>
</body>
</html>

Solutions

Expert Solution

Hi,

I have done this script as Temperature Conversion Calculator.this convert Celsius to Fahrenheit and vise versa.

Below is script:

HTML form:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title></head>

<body>
<p>Convert Temp</p>
<form id="form1" name="form1" method="POST" action="hw8.php">
  <table width="300" border="1">
    <tr>
      <td width="122">Enter Temp </td>
      <td width="168"><label>
        <input name="temp" type="text" id="temp" size="6" maxlength="8" />
      </label></td>
    </tr>
    <tr>
      <td>Convert to &gt;&gt;&gt; </td>
      <td><p>
        <label></label>
        <label>
        <input name="type" type="radio" value="f" checked="checked" />
Fahrenheit</label>
        <br />
        <label>
        <input type="radio" name="type" value="c" />
Celcius</label>
        <br />
        <br />
      </p></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><label>
        <input type="submit" name="Submit" value="Submit" />
      </label></td>
    </tr>
  </table>
</form>
<p><a href="index.html">return</a></p>
</body>
</html>

PHP Script:

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
    $temp  = $_POST["temp"]; 
        $type = $_POST["type"];
    $fr = 0;
        if($type=="c"){
       $fr = ($temp - 32)/1.8;
        }
        else{
                echo 
       $fr = ($temp*1.8)+32;
        }
          
   
}
?>




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Temperature Convertor</title>
</head>

<body>
<p>Temperature Conversion</p>
<?php        if($type=="c"){
 ?>
<p>You converted  Fahrenheit to Celsius : <?php echo $fr ?><br></p>
<?php 
}
 else{
 ?>
  <p>You converted  Celsius to Fahrenheit : <?php echo $fr ?><br></p>

 <?php 
 }
 ?>
<p><a href="index.html">return</a></p>
</body>
</html>

Output screen:

1. Celsius to Fahrenheit :

2. Fahrenheit to Celsius

Thanks


Related Solutions

Develop a form to display centigrade temperature and corresponding Fahrenheit temperature ranging from 30 to 90...
Develop a form to display centigrade temperature and corresponding Fahrenheit temperature ranging from 30 to 90 at increments of 10. Use a do while loop. Please use the below formula to convert Celsius to Fahrenheit in advance C# I need the form not a table. Thank you!
Convert the boiling temperature of gold, 2966 °C, into degrees Fahrenheit and kelvin.
Convert the boiling temperature of gold, 2966 °C, into degrees Fahrenheit and kelvin.  
At what temperatures values are the following scales the same? (a) The Fahrenheit and the Celsius   ...
At what temperatures values are the following scales the same? (a) The Fahrenheit and the Celsius    (b) The Celsius and the Kelvin     (c) The Fahrenheit and the Kelvin  
In Java: Write a program called F2C that allows the user to convert from degrees Fahrenheit...
In Java: Write a program called F2C that allows the user to convert from degrees Fahrenheit to degrees Celsius. The program should prompt for a temperature in Fahrenheit and output a temperature in Celsius. All calculations should be done in in ints, so be careful of truncation.
Write a java program to convert Celsius degrees to Fahrenheit degrees the user enters degrees in...
Write a java program to convert Celsius degrees to Fahrenheit degrees the user enters degrees in Celsius and the program Coverts the input to Fahrenheit using the following formula T(°F) = T(°C) × 1.8 + 32 submit the source code Design output Load: 1. Design (Pseudocode ) 2. Source file (Java file, make sure to include comments) 3. Output file (word or pdf or jpig file)
Temperature Converter Create a temperature conversion program that will convert the following to Fahrenheit: Celsius Kelvin...
Temperature Converter Create a temperature conversion program that will convert the following to Fahrenheit: Celsius Kelvin Newton Your program should take a character which represents the temperature to convert from and a value to be converted to using the following specification: C - Celsius K - Kelvin N - Newton In addition your program should take in the following character to exit the program: X - eXit the program The numeric input for your program should be of type double....
how much heat kj is required to convert 20g ice cube at -10 degrees celcius into...
how much heat kj is required to convert 20g ice cube at -10 degrees celcius into water vapor at 100 degrees celcius?
Convert the decimal number, 315.56 into binary form?
Convert the decimal number, 315.56 into binary form?
Convert the following values into binary numbers for each word and place the binary values in...
Convert the following values into binary numbers for each word and place the binary values in the two-dimensional array in their proper order of words. Value Binary Number Equivalent Word 0 462,91210 Word 1 1142008 Word 2 5420h Word 3 20,992d Word 4 1104208 Word 5 6102008 Word 6 9F88h Word 7 20,49610 Word 8 502416 Word 9 1101018 Word 10 71082h
1. Develop a module named temperatures.py with the following functions. Function toCelsius is passed a Fahrenheit...
1. Develop a module named temperatures.py with the following functions. Function toCelsius is passed a Fahrenheit temperature and returns the Celsius equivalent. 1 degree Fahrenheit = 5/9 * (Fahreheit-32) degrees Celsius. Function toFahrenheit is passed a Celsius temperature and returns the Fahrenheit equivalent. 1 degree Celsius = 1.8*Celsisus + 32 degrees Fahrenheit. Function toKPH is passed a speed in miles per hour and returns the kilometers per hour equivalent. 1 kph = mph * 1.609344 Function toMPH is passed a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT