Please Help with PHP

Reply

Join Date: Jun 2009
Posts: 38
Reputation: Jintu is an unknown quantity at this point 
Solved Threads: 0
Jintu Jintu is offline Offline
Light Poster

Please Help with PHP

 
0
  #1
Jul 2nd, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 953
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 125
ardav's Avatar
ardav ardav is online now Online
Posting Shark

Re: Please Help with PHP

 
0
  #2
Jul 2nd, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 38
Reputation: Jintu is an unknown quantity at this point 
Solved Threads: 0
Jintu Jintu is offline Offline
Light Poster

Re: Please Help with PHP

 
0
  #3
Jul 2nd, 2009
<!--
// Date: Thursday July 2nd 2009
// Purpose: Write a PHP program to output the volume of Spam that can fit into a can
-->
  1. <html>
  2. <head>
  3. <title>My First PHP Page</title>
  4. </head>
  5. <body>
  6. <?php
  7. 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.!";
  8. $height = 8.1;
  9. $width = 10.5;
  10. $breadth = 4.2;
  11. $cubes = 1;
  12. $multiplication = $height * $width *$breadth;
  13. echo "Volume of a can of spam: $height * $width *$breadth = ".$multiplication."<br />";
  14. $division = $multiplication / $cubes;
  15. echo "Number of 1cc cubes that can be cut from the same volume of Spam: $multiplication / $cubes = ".$division."<br />";
  16.  
  17. ?>
  18.  
  19.  
  20. </body>
  21. </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
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 57
Reputation: emarshah is an unknown quantity at this point 
Solved Threads: 5
emarshah emarshah is offline Offline
Junior Poster in Training

Re: Please Help with PHP

 
0
  #4
Jul 3rd, 2009
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.
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---------------------------
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 953
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 125
ardav's Avatar
ardav ardav is online now Online
Posting Shark

Re: Please Help with PHP

 
0
  #5
Jul 3rd, 2009
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.
"...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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 953
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 125
ardav's Avatar
ardav ardav is online now Online
Posting Shark

Re: Please Help with PHP

 
0
  #6
Jul 3rd, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 38
Reputation: Jintu is an unknown quantity at this point 
Solved Threads: 0
Jintu Jintu is offline Offline
Light Poster

Re: Please Help with PHP

 
0
  #7
Jul 4th, 2009
Originally Posted by ardav View Post
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.
Hi, thank you so much for your help, can I ask for your clarification of this part, I dun quite understand what you mean?:
(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
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 953
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 125
ardav's Avatar
ardav ardav is online now Online
Posting Shark

Re: Please Help with PHP

 
0
  #8
Jul 4th, 2009
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC