CSci 1101 Lab 2. Due Wedn. Sept. 27 at 10pm

Celsius/Fahrenheit conversion

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
Last modified: 2/9/06
-->
<?php
$celsius = -5.5;
?>
<html>
<head>
<title>
Celsius/Fahrenheit converter
</title>
</head>
<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.
  2. Using sftp, upload this file to rynite into your public_html (or its subdirectory).
  3. Type in the URL of the file in your browser to make sure that it works as it should.
  4. 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.
  5. Add another paragraph to the page to display the temperature in degrees Fahrenheit. Upload the file to rynite and make sure it works.
  6. Change the value of the variable celsius, upload the file to rynite. Make sure that the temperature in Fahrenheit changed as well.

Madlibs game in PHP

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
Last modified: 2/9/06
-->
<?php
$person = "someone";
$place = "somewhere";
$object = "something";
?>
<html>
<head>
<title>
Madlibs page: change the variables and read a new story
</title>
</head>
<body>
<h2>Madlibs page: change the variables and read a new story</h2>

<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 so that when the program is run, the values of these variables are displayed. After you add a sentence upload the file to rynite, make sure that the program works. Add another sentence, upload again. Continue until the story is completed. Change the values of the three variables, upload the file again, and make sure that the story has changed.

Giving input to your program using extended URL (optional)

If you have time, change your Madlibs program to get input through URL. Use this example. Do not give input that has spaces in it - you need to use special characters for spaces in extended URLs.

To submit

Just upload the two files to rynite.

This page is a part of CSci 1101 course web site.