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

PYTHON: Complete these functions in the module: f2c, a function to convert Fahrenheit temperatures to Celcius....
PYTHON: Complete these functions in the module: f2c, a function to convert Fahrenheit temperatures to Celcius. c2f, a function to convert Celcius termperatures to Fahrenheit. Write f2c() and c2f() as functions that return a true value or False. In other words, these functions do not print — they return. A "true value", in this case, would be a number that corresponds to a temperature. If the user enters an invalid temperature, the function should return False. Create _main(), a function...
1. Write a C++ code segment to read 50 temperature values in Fahrenheit and to convert...
1. Write a C++ code segment to read 50 temperature values in Fahrenheit and to convert them to Celsius. You convert a Fahrenheit temperature to Celsius by using the following formula: Celsius = 5.0 / 9 * (Fahrenheit - 32). 2.A client has purchased 20 products in a store. Write a C++ code segment to read the unit price and the number of items of each product and to compute and print the total price of all these products.
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!
Write a fragment of MIPS code to convert temperature in Kelvin to Fahrenheit
Write a fragment of MIPS code to convert temperature in Kelvin to Fahrenheit
a. Celsius and Fahrenheit scales have zero values. Why are they not ratio scales? b. Provide...
a. Celsius and Fahrenheit scales have zero values. Why are they not ratio scales? b. Provide an example of an interval scale not mentioned in the text that is not a ratio scale. If you scale has a zero element, briefly explain why the zero element does not make it a ratio scale. c. Provide an example of a ratio scale not mentioned in the text. Briefly explain why the zero element of your scale makes it a ratio scale.
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.  
in java Write a program that convert a Fahrenheit to Celsius. For conversion, use as many...
in java Write a program that convert a Fahrenheit to Celsius. For conversion, use as many as methods you want
Java Script Ask the user for a Fahrenheit temperature Write the code needed to convert a...
Java Script Ask the user for a Fahrenheit temperature Write the code needed to convert a Fahrenheit temperature into a Celsius temperature. Use an alert box to show the result Ask the user for a Celsius temperature Write a function to convert from Celsius to Fahrenheit; use an alert box to show the results Decide on two other conversions (meters to feet, pounds to kilos, other) Ask the user for numbers to be converted; be sure to tell them what...
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  
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?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT