Threesuns

Email the Instructor

Contact

All Semesters

Semesters

All Courses

Courses

2012Spring

01.09.12 - 05.06.12

PHP Programming (Blended)

CSYS2463

Monday Wednesday
01:00 PM - 02:20 PM

Planet Weight Calculator

Lab03

Objective: Practice using Control Structures

pastdue

Submit Your Solution

Lab03

Request a Copy of your Solution

Lab03

Requirements

Comments placed the source code file5 pts
Page contains required sections and parts10 pts
Page shows correct image for selected planet15 pts
Page performs calculation to find relative weights20 pts
The special conditions to the calculation are recognize and handled 10 pts
Form retains data from previous submissions25 pts
Page format is correct and valid in all circumstances5 pts
Planet gravity data is read from supplied data file10 pts
Total100 pts

Instructions

For this lab you will need to create a web page that will allow a person to enter what an item weights on Earth and to then select a planet in our solar system to see what the weight would be given that planet's relative gravity to Earth. The page should contain three sections, perform the calculation to find the relative weight, display an image, and recognize two special conditions.

Page Sections:

The first section should include controls to allow a client to enter the weight of something on Earth (a textfield), a select component to choose a planet in our Solar System (Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto (Yes, we're assuming that Pluto is still considered a planet)), and a submit button. Each of these controls should contain default values (blank for the textfield, Mercury for the select) the first time the page is visited and should then retain values entered by the user from that point forward. For example, if the user visits the page for the first time and enters 200 in the textfield and selected Jupiter from the select, after they press submit these values should be kept in the same fields so that the user does not need to reenter any more than they wish to change.

The second section should be an output section that displays a default message if no Earth weight has been entered (i.e. "You must input an Earth Weight") and displays the calculated (relative) weight if an Earth weight has been entered based on the selected planet.

The third section should display an image of the planet that is currently selected in the select component described in section 1. The pictures are available in the file PlanetImages.zip.

The Calculation:

The calculation to find the relative weight on another planet is simple. You would multiply the Earth weight and the relative gravity for the selected planet. These relative gravity values are given in the PLANET.TXT file. The file is space delimited where each record (line) represents one planet and contain two fields, the first is the name of the planet and the second is the relative gravity to Earth's, so Earths relative gravity to Earth is 1.0 (100%), Mars's relative gravity is .38 (38%) of Earth's, etc. The relative weight that is found through this calculation should be displayed in a readable format in the output section described above.

Special Conditions:

There are two exceptions to the normal working of this script. One is if the client entered an Earth weight and then selects Earth. In this case the calculation should not be performed but instead a message telling the user that the calculation is pointless should be displayed.

The second exception is with Pluto where there is not enough information available about the planet to calculate its gravity (shown as 0 in the PLANET.TXT file) , in the case where the client selects Pluto a message should be displayed explaining this situation to them.

For this lab you may not change the names or locations of the images (they must be called Planet1-9.jpg and be located in a PlanetImages directory below the directory containing your script). When turning in the lab you should only submit your script, not the images or the PLANET.TXT file.

Extras