## CSci 1101 Lab 3. Due Wednesday, Feb. 17th at 11:59pm

### Celsius/Fahrenheit conversion (6 points)

You are given a php program that has a variable \$celsius for temperature in celsius:

``````

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!--
Celsius/Fahrenheit converter
Author: Elena Machkasova elenam@morris.umn.edu
-->
<?php
\$celsius = -5.5;
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

<title>
Celsius/Fahrenheit converter
</title>

<body>

<p>The current temperature is <? print \$celsius?>C. </p>

</body>
</html>
``````
1. Start jedit, copy/paste this code into a file temperature.php, save the file into your public_html directory (or its subdirectory).
2. Type in the URL of the file in your browser to make sure that it works as it should.
3. Add another variable \$fahrenheit to the program. This variable should compute the corresponding temperature in Fahrenheit according to the following formula:

Tf = (9/5)*Tc+32; Tc = temperature in degrees Celsius, Tf = temperature in degrees Fahrenheit.

Convert this formula into PHP, use the variable \$celsius for temperature in celsius.
4. Add another paragraph to the page to display the temperature in degrees Fahrenheit. Save the file, reload it in the browser, and make sure it works.
5. Change the value of the variable celsius, save the file. Check that the temperature in Fahrenheit changed as well.
6. Make sure your page is XHTML-valid.

### Madlibs game in PHP (6 points)

You are given the following code that you need to save in a file madlibs.php

``````
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!--
Lab 3 PHP problem
Author: Elena Machkasova elenam@morris.umn.edu
-->
<?php
\$person = "someone";
\$place = "somewhere";
\$object = "something";
?>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>

</title>

<body>

<p>
<!-- Here goes your story -->

</p>

</body>

</html>

``````

Your task is to write a story that has in it a person, a place, and an object (at least two of these should be used more than once in the story). Use the php variables \$person, \$place, and \$object. After you add a sentence, save the file and make sure that the program works. Add another sentence, save and check again. Continue until the story is completed. Change the values of the three variables, save the file again, and make sure that the story has changed.

Make sure your page is XHTML-valid.

### Input for temperature problem (3 points)

Change the program so that the temperature is passed as an input in an extended URL, i.e. when you add `?input=-20` to the URL in your browser, the Celsius temperature changes to that number. Use this program as an example.

Make sure your page is XHTML-valid. You may submit just one file for the temperature program or two separate ones: with and without the input.

#### To submit

Save the final versions of the files on csci1101sp10 and do not modify them after the deadline. Send me the URLs of the files.