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.

Member Avatar for diafol

What the hell are you doing ****? Stop wasting time and get on with your assignment. The clock's ticking. Chortle.

<!--
// Date: Thursday July 2nd 2009
// Purpose: Write a PHP program to output the volume of Spam that can fit into a can
-->

<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

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.

Member Avatar for diafol

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.

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

Member Avatar for diafol

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.