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!
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 this into Chomsky normal form, where each rule is in the form: A --> BC...
Convert this into Chomsky normal form, where each rule is in the form: A --> BC or A --> a A --> A + B | B B --> B x C | C C --> (A) | 5
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT