There are six parts to this week's lab sheet.
Put the work for the first five parts of this lab into a new folder
public_html\cs1109\lab6
.
Copy pet.html
and pet.php
from your
lab5
folder into your lab6
folder.
Modify pet.php
so that, instead of using a sequence of
echo
statements, it now uses at most one echo
statement. This echo
statement must use concatenation
to produce the output.
Copy spy.html
and spy.php
from your
lab5
folder into your lab6
folder.
Modify spy.php
so that, instead of using a sequence of
echo
statements, it now uses at most one echo
statement. This echo
statement must use interpolation to
produce the output.
Take a copy of pints.html
; do not
modify it. It allows a user to enter the number of pints of some unspecified
liquid that s/he has consumed.
You must write pints.php
which converts from pints
to quarts, and to fluid ounces, and to gills. The information that you need is
that 1 pint is ½ quart; 1 pint is 16 fluid ounces; and 1 gill is 4 fluid ounces.
The output should be a table, and should validate. Here's an example for a user who consumed 3 pints:
Pints | Quarts | Fluid ounces | Gills |
---|---|---|---|
3 | 1.5 | 48 | 12 |
You can take a copy of this stylesheet if you want to style the table so that it looks like mine.
Make sure the output validates.
Take a copy of weight.html
; do not
modify it. It allows a user to enter his/her weight in kilogrammes.
You must write weight.php
which converts the user's
weight from kilogrammes to stones and pounds (rounding down).
For example, if the user enters 60 (i.e. 60 kilogrammes), then the output is this paragraph:
You weigh 60 kg, which is 9 stone and 6 pounds.
One observation is: you're unlikely to be able to write this program if you aren't able to manually convert kg to stones/pounds. In other words, think about how a human would do this conversion.
And here's even more help…You might find it easier to break this problem down, as follows.
You can, of course, approach the problem in a different way if you wish.
In their pockets, citizens of the United States carry a number of coins of different values: cents, nickels (each worth 5 cents), dimes (each worth 10 cents), quarters (each worth 25 cents), half dollars (each worth 50 cents), and dollars (each worth 100 cents). They also carry a number of notes of different denominations: 1 dollar notes, 2 dollar notes, 5 dollars, 10 dollars, 20 dollars, 50 dollars, and 100 dollars.
In a file called cash.html
, create a form that satisfies
the following requirements:
form
, fieldset
,
legend
, div
, label
and input
cash.php
using the get
method.
There is no requirement to add access keys.
In a file called cash.php
write a PHP script which takes the data
that the user entered into the form and computes in cents
the total amount of money the
user has in his/her pockets. Example output for a user who has three dimes,
five quarters and one 10 dollar bill is as follows:
You have 1155 cents.
Make sure the output validates.
Finally, create a CSS3 stylesheet called cash.css
that presents your
form as attractively as possible. E.g. it may line up labels; it may line
up textboxes; it may improve borders; it may improve spacing; it may add some colour
or even background images; and so on. Make sure it too validates.
Deadline for Parts 1, 2, 3, 4 and 5: 1pm, Tuesday 20th November.
If you have named your files and folders correctly, your work will be collected automatically at that time by my software.
This final activity is bigger than usual. You should start it today but you don't have to finish this week. In fact, it should occupy you for the next few weeks. Be aware though that we will continue to issue lab sheets on a weekly basis.
The goal is to produce a personal web site. It must be high-quality, multi-page, reasonably ambitious, and your own original work. Put some personality into it!
Pages might cover: interests, hobbies, the Computer Science degree, your home town,… or anything really! You decide.
If you want to do something other than a personal website (e.g. a website for your family's business, or your local hurling team, etc.), then check with me first.
Take into account everything we've covered:
Put this work directly into your public_html
folder
replacing the web site that you built during Induction. (In other words, this
web site does not go into your cs1109
folder. And
delete any crud left over from Induction.)
Make sure the home page is called index.html
.
You can decide what to call the other files.
There is no extra credit for using PHP in this web site. However, if you want to use it
(e.g. to add the date and time to some or all of the pages), then you can. In this case,
the home page will be called index.php
, rather than index.html
.
Deadline for Part 6: 1pm, Wednesday 9th January. Start it now; don't leave it to the last minute. And remember that UCC is closed from Monday 24th December 2010 to Tuesday 1st January 2012 inclusive.