| | |
Please Help with PHP
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2009
Posts: 38
Reputation:
Solved Threads: 0
CAREFULLY READ ALL OF THIS PAGE BEFORE STARTING THE ASSIGNMENT
Cans of luncheon meat (e.g. Spam) are quite often irregularly shaped with a special tool on top to open them:
Can of Spam
You can estimate the volume (in cubic centimeters) of a can of Spam by multiplying the height by the width by the breadth of the can (all measurements in centimeters).
Today's assignment is a team assignment.
This is the deal - whichever team completes the assignment most correctly and in the shortest time, that team's leader will be designated "Top Student" for the CSCI165A Summer 2009 Semester and will be invited on the Awards Ceremony cruise on the last day of classes. The winning team members receive one bonus point - to be calculated into their grade after the end of the course.
To be fair to all teams, the instructor will give no help at all on this assignment - she will be drinking coffee and surfing the net...
No, seriously now...
I will be seeing students individually to discuss their performance on the course so far, and return any unreturned papers.
The assignment instructions:
Write a PHP program to output the volume of Spam that can fit into a can
of height 8.1 cm, width 10.5 cm and breadth 4.2 cm.
Your program should also calculate and output how many 1cc cubes can be cut from the same volume of Spam, to serve to the guests on the Coquitlam College Awards Cruise.
The program has no inputs. Values are assigned to variables which are then processed in your program. Comments in the code list all team members.
START HERE
Study the PHP resources:
Example PHP Scripts (i.e. PHP programs)
DO NOT use the Internet Explorer browser for this course.
IE doesn't display the course resources correctly.
You have been warned.
Introduction to PHP
PHP Tutorial
PHP Tutorial - PHP Basic Section - Topics to study:
PHP Intro
PHP Syntax
PHP Variables
PHP String
PHP Operators
Skim these resources:
PHP if...else
PHP Looping - for
PHP Looping - while
PHP Functions
Deadline is end of class today.
The team leader ONLY will submit this assignment
by entering the URL to the PHP file in the online text box.
(Scroll down this page and click on the
"Edit my submission" button.)
You will need to upload your PHP file to your webspace on the webserver before it can be run and tested.
PHP is NOT installed on the computers in Room 1.
Cans of luncheon meat (e.g. Spam) are quite often irregularly shaped with a special tool on top to open them:
Can of Spam
You can estimate the volume (in cubic centimeters) of a can of Spam by multiplying the height by the width by the breadth of the can (all measurements in centimeters).
Today's assignment is a team assignment.
This is the deal - whichever team completes the assignment most correctly and in the shortest time, that team's leader will be designated "Top Student" for the CSCI165A Summer 2009 Semester and will be invited on the Awards Ceremony cruise on the last day of classes. The winning team members receive one bonus point - to be calculated into their grade after the end of the course.
To be fair to all teams, the instructor will give no help at all on this assignment - she will be drinking coffee and surfing the net...
No, seriously now...
I will be seeing students individually to discuss their performance on the course so far, and return any unreturned papers.
The assignment instructions:
Write a PHP program to output the volume of Spam that can fit into a can
of height 8.1 cm, width 10.5 cm and breadth 4.2 cm.
Your program should also calculate and output how many 1cc cubes can be cut from the same volume of Spam, to serve to the guests on the Coquitlam College Awards Cruise.
The program has no inputs. Values are assigned to variables which are then processed in your program. Comments in the code list all team members.
START HERE
Study the PHP resources:
Example PHP Scripts (i.e. PHP programs)
DO NOT use the Internet Explorer browser for this course.
IE doesn't display the course resources correctly.
You have been warned.
Introduction to PHP
PHP Tutorial
PHP Tutorial - PHP Basic Section - Topics to study:
PHP Intro
PHP Syntax
PHP Variables
PHP String
PHP Operators
Skim these resources:
PHP if...else
PHP Looping - for
PHP Looping - while
PHP Functions
Deadline is end of class today.
The team leader ONLY will submit this assignment
by entering the URL to the PHP file in the online text box.
(Scroll down this page and click on the
"Edit my submission" button.)
You will need to upload your PHP file to your webspace on the webserver before it can be run and tested.
PHP is NOT installed on the computers in Room 1.
What the hell are you doing ****? Stop wasting time and get on with your assignment. The clock's ticking. Chortle.
Last edited by ardav; Jul 2nd, 2009 at 3:59 pm.
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
All opinions count.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
•
•
Join Date: Jun 2009
Posts: 38
Reputation:
Solved Threads: 0
<!--
// Date: Thursday July 2nd 2009
// Purpose: Write a PHP program to output the volume of Spam that can fit into a can
-->
Is my code correct, if not, please give me some valuable advice on how to improve it....
Thanks,
Tony
// Date: Thursday July 2nd 2009
// Purpose: Write a PHP program to output the volume of Spam that can fit into a can
-->
php Syntax (Toggle Plain Text)
<html> <head> <title>My First PHP Page</title> </head> <body> <?php echo "This program calculates the volume of Spam that can fit into a can of height 8.1 cm, width 10.5 cm and breadth 4.2 cm.!"; $height = 8.1; $width = 10.5; $breadth = 4.2; $cubes = 1; $multiplication = $height * $width *$breadth; echo "Volume of a can of spam: $height * $width *$breadth = ".$multiplication."<br />"; $division = $multiplication / $cubes; echo "Number of 1cc cubes that can be cut from the same volume of Spam: $multiplication / $cubes = ".$division."<br />"; ?> </body> </html>
Is my code correct, if not, please give me some valuable advice on how to improve it....
Thanks,
Tony
Last edited by peter_budo; Jul 3rd, 2009 at 9:39 am. Reason: K
•
•
Join Date: Jan 2008
Posts: 57
Reputation:
Solved Threads: 5
Hello,
There is no problem with the code as for as errors are concern, now its up to you that the formulas you put are correct and according to requirements or not..... I think that you are not considering well the " 1 cc " of the cans, do consider this, it will help you.
Hope you will do this beautifully.
There is no problem with the code as for as errors are concern, now its up to you that the formulas you put are correct and according to requirements or not..... I think that you are not considering well the " 1 cc " of the cans, do consider this, it will help you.
Hope you will do this beautifully.
Last edited by emarshah; Jul 3rd, 2009 at 3:07 am.
Syed Ammar Hassan
" A man is known by his level of Determinism "
--------------------------------------------------------
"Some cause happiness where ever they go, others whenever They go"
--------------------------XIII---------------------------
" A man is known by his level of Determinism "
--------------------------------------------------------
"Some cause happiness where ever they go, others whenever They go"
--------------------------XIII---------------------------
Seeing as this is an assignment, you're pretty much on your own. However, a few ideas:
1. Get a php enabled pc - I bet one of your team has a laptop/PC and download XAMPP.
2. Create the file (Notepad will do).
3. Insert a form (for can dimensions - just 3 input boxes and a submit button).
4. Send the form to itself (for ease - although you wouldn't normally do this).
5. Grab the $_POST variable form data and do your calculations on it - remember to check for non-numerical input -> throw an error message.
6. Output your answer somewhere on the screen along with the original 'question'.
If you find any advice on this forum useful, we fully expect to be invited to the Awards Ceremony Cruise, travelling expenses included.
BTW - does 1cc cubes take into account the amount wasted? i.e. if dims are 4.5 x 4.5 x 4.5 - you'll only be getting 4 x 4 x 4 = 64 cubes, or are you taking 91 (an a bit) cubes as the answer? That could be a nice twist to include maybe. Look at floor/ceil functions.
1. Get a php enabled pc - I bet one of your team has a laptop/PC and download XAMPP.
2. Create the file (Notepad will do).
3. Insert a form (for can dimensions - just 3 input boxes and a submit button).
4. Send the form to itself (for ease - although you wouldn't normally do this).
5. Grab the $_POST variable form data and do your calculations on it - remember to check for non-numerical input -> throw an error message.
6. Output your answer somewhere on the screen along with the original 'question'.
If you find any advice on this forum useful, we fully expect to be invited to the Awards Ceremony Cruise, travelling expenses included.
BTW - does 1cc cubes take into account the amount wasted? i.e. if dims are 4.5 x 4.5 x 4.5 - you'll only be getting 4 x 4 x 4 = 64 cubes, or are you taking 91 (an a bit) cubes as the answer? That could be a nice twist to include maybe. Look at floor/ceil functions.
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
All opinions count.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
Look here: http://www.wetwork.org.uk/spam.php for an example of what I mean.
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
All opinions count.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
•
•
Join Date: Jun 2009
Posts: 38
Reputation:
Solved Threads: 0
•
•
•
•
Seeing as this is an assignment, you're pretty much on your own. However, a few ideas:
1. Get a php enabled pc - I bet one of your team has a laptop/PC and download XAMPP.
2. Create the file (Notepad will do).
3. Insert a form (for can dimensions - just 3 input boxes and a submit button).
4. Send the form to itself (for ease - although you wouldn't normally do this).
5. Grab the $_POST variable form data and do your calculations on it - remember to check for non-numerical input -> throw an error message.
6. Output your answer somewhere on the screen along with the original 'question'.
If you find any advice on this forum useful, we fully expect to be invited to the Awards Ceremony Cruise, travelling expenses included.
BTW - does 1cc cubes take into account the amount wasted? i.e. if dims are 4.5 x 4.5 x 4.5 - you'll only be getting 4 x 4 x 4 = 64 cubes, or are you taking 91 (an a bit) cubes as the answer? That could be a nice twist to include maybe. Look at floor/ceil functions.
(BTW - does 1cc cubes take into account the amount wasted? i.e. if dims are 4.5 x 4.5 x 4.5 - you'll only be getting 4 x 4 x 4 = 64 cubes, or are you taking 91 (an a bit) cubes as the answer? That could be a nice twist to include maybe.)
Thanks, again...
Tony
Sure, if you're creating a cuboid, say 4.5 cm x 4.5 cm x 4.5 cm. You'll get a lot of wastage, because you can only cut 1 x 1 x 1 cubes. So, although the total volume of the spam will be 91.125 cm3 (or cc), you can only create 4 x 4 x 4 = 64 cubes (wasting 27.125 cm3), unless you perfectly remould the leftovers to get 91 cubes with a little speck left over (0.125cm3). Anyway, take a look at the link in my previous post ( http://www.wetwork.org.uk/spam.php ) it should show you what I mean.
Last edited by ardav; Jul 4th, 2009 at 10:02 am.
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
All opinions count.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
![]() |
Similar Threads
- Project available for PHP Developer (Web Development Job Offers)
- PHP/MySQL Programmer Position (Web Development Job Offers)
- Are you a PHP and Javascript junkie? It's time you met Emma. (Software Development Job Offers)
- PHP MYSQL Developer Position Available (Web Development Job Offers)
- PHP Web Programmer (Post your Resume)
- PHP / My SQL Web developer (Web Development Job Offers)
Other Threads in the PHP Forum
- Previous Thread: Sortable table
- Next Thread: Using PhP BB
| Thread Tools | Search this Thread |
.htaccess alerts apache api archive array autocomplete beginner binary broken cakephp checkbox class cms code convert cron curl database dataentry date display duplicates dynamic echo email emptydisplayvalue error execute explodefunction file files firstoptioninphpdroplist folder form forms function functions google hack href htaccess html htmlspecialchars image include insert ip javasciptvalidation javascript joomla keywords limit link login mail matching menu methods mlm multiple mysql network object oop paypal pdf php problem query radio random recursion recursive redirect remote script search securephp server sessions shot sms source space sql subscription syntax system table tutorial tutorials update upload url validator variable video web youtube





