Programming Assignment: Fish Pond Overview For this assignment, you will create a program that calculates the dimensions for various fish pond configurations. Specifically, the program will calculate...


Programming Assignment: Fish Pond


Overview


For this assignment, you will create a program that calculates the dimensions for various fish pond configurations. Specifically, the program will calculate the volume for the pond in cubic feet, the surface area of thesides and bottomof the fish pond, and the area of a 2-foot wide border around the edge of the pond.


Ponds come in predefined sizes and shapes.


There are:



  • circular ponds, diameter: 5 feet



  • square ponds, side: 5 feet



  • rectangular ponds, dimensions: 4 feet by 7 feet



  • ovoid ponds, dimensions: 4 feet by 6 feet
    The "oval" can be decomposed into two semicircles attached to a rectangle.



  • "L"-shaped ponds: overall dimensions: 6 feet by 10 feet
    The "L" can be decomposed into three smaller rectangles; alternately, it could be viewed as a large rectangle with a corner excised.




The basic depth of a pond is 24 inches. For the Challenge option, depth is variable: 18, 24, or 30 inches deep. Remember that 12 inches is one foot, so these values translate into 1.5, 2.0, or 2.5 feet deep, respectively.


Educational objectives



  • Gather information from the user

  • Perform mathematical calculations

  • Display results to specified accuracy


Instructions


The program shall ask the user for the characteristics of the desired fish pond:



  • the shape:circle,square,rectangle,oval,L

  • the depth (for the challenge option):18,24,30


The only acceptable input values are those listed in bold above.


Based on the user's input values, the program shall calculate and report the statistics for the requested pond:



  • the volume in cubic feet

  • the surface area of the sides and bottom

  • the surface area for a two-foot wide border around the pond (Standard and Challenge versions)


This assignment has Minimal, Standard, and Challenge versions.


Minimal version


The minimal version corresponds roughly to a "B-" version of the assignment.


For the minimal version, the program can assume that the user always types accurately. So, if the user does not enter one of the expected values, the behavior of the program is undefined. That is, it could crash, it could end without generating any output, it could …


Sample run, Minimal version


The user input is shown in blue bold text.



Fish ponds are available in the following shapes:
circle, square, rectangle, oval, L
Please select the shape for your fish pond:square

The volume of your fish pond is 50.000 cubic feet.
The surface area of your fish pond is 65.000 square feet.



The volume is determined by the area of the base times the depth. In this case, the square base has area 25, 5x5, and the depth is 2 feet. So, 50 cubic feet, printed with three places after the decimal point.


The surface area is actually just the area of the sides and bottom of the pond. There are four sides, each 5x2, for the area of the sides of 40 square feet. As noted above, the area of the bottom is 25 square feet. This gives a total surface area of 65 square feet, also reported with three places following the decimal point.


Sample run, Minimal version


The user input is shown in blue bold text.



Fish ponds are available in the following shapes:
circle, square, rectangle, oval, L
Please select the shape for your fish pond:circle

The volume of your fish pond is 39.270 cubic feet.
The surface area of your fish pond is 51.051 square feet.



The volume is determined by the area of the base times the depth. In this case, the base is circular, so its area is π r2, that is, π · 2.52, or approximately 19.634954 square feet, and the depth is 2 feet. So, approximately 39.269908 cubic feet, printed with three places after the decimal point, 39.270.


The surface area is actually just the area of the sides and bottom of the pond. There is one circular side whose area is the circumference of the base times the depth. The circumference of the base is 2π r, or 2π · 2.5 feet; and the depth is 2 feet. So, the area of the sides is approximately 31.415927 square feet. As noted above, the area of the bottom is approximately 19.634954 square feet. This gives a total surface area of approximately 51.050881 square feet, also reported with three places following the decimal point, 51.051.


Notes for Minimal Versions



  • The script shall prompt the user for the shape of the desired fish pond.

  • The prompt for the shape shall include the acceptable values: circle, square, rectangle, oval, and L.

  • The script shall only process a single fish pond. After the one pond is done, the script shall end.

  • The calculated values shall all bereportedto the thousandths, three places after the decimal point.

  • For the minimal version, the values for the volume and surface area can be hard-coded into the output string, that is, you could just type the correct numbers into the program, as given in the table below. (This will be different for the Standard and Challenge versions of the assignment, where the computer will need to do the calculations.)

  • Target values for the volume and area for the Minimal version:


































    ShapeVolumeArea
    Square50.00065.000
    Circle39.27051.051
    Rectangle56.00072.000
    Oval41.13353.699
    L90.000109.000



Report


In addition to the Python script, the assignment includes a brief written report that answers the following questions:



  • How did you approach (get started with) this assignment?

  • How did you test your program?

  • What works and what doesn't work?

  • What did you learn from this assignment? What would you do differently next time?


Submit the written report in the same submission as the Python script.


Notes about the Report



  • The written report does not have to be long. A paragraph or two is probably sufficient for this assignment.

  • The file format for written report is ASCII text (.txt file). As a plain text file, you don't have to worry about issues like bold, italics, images. It should make it simpler.

  • You may find it easier to write the written report if you start it early and take notes about the process as you work through the problem, rather than trying to write the report at the end, from memory.

  • The final question: "What would you do differently next time?" is asking about how you would approach the next programming assignment based on what you learned in this assignment. It is not about this specific programming problem.

  • Put your name and this assignment number and name at the top of the written report.


Standard version


There are two enhancements for the Standard version over the Minimal version:



  • The program will perform the calculations within the script file.

  • Reported the area of a two-foot wide border around the pond.


The program will still assume that the user input is accurate. If unexpected values are entered, the behavior of the script is "undefined".


Program-Internal Calculations


For the Minimal version, you could calculate the values for the volume and surface area external to the Python script and just print out the numbers. For the Standard and Challenge versions,allof the calculations must be present within the Python script.



  • The script shall calculate the values based on the dimensions given above and the user's input. That is, the script needs to calculate the volume and area, rather than just output precalculated values.

  • The script shall usemath.pifor the value of π, rather than some other approximation.
    Note: To use the valuemath.pi, your script file will need to include the following declaration toward the top of the script, after the header comment:import math


The values can be used for the shapes are the ones that appear on the schematic diagrams of the shapes. They are repeated in the table below.































Shape

Given
Values
circle5
square5
rectangle4, 7
oval4, 6
L3, 6, 5, 10


Let's see how this would work. As an example, here are the calculations for a circular pond of the standard depth, 24 inches.



The base of the pond is a circle, 5 feet in diameter. So, the radius is 5/2 or 2.5 feet.
The area of the base is the area of the circle, π ·r
2.
The perimeter of the base is the circumference of the circle, 2π ·r.
The depth is 24 inches, or 2 feet.
So, the volume is the area of the base times the depth.
The surface area is the area of the base plus the area of the sides.
The area of the sides is the depth times the perimeter of the base.



Converting this into Python is pretty straight forward:



r =5/ 2
base_area = math.pi * r ** 2
base_perim = 2 * math.pi * r
depth = 2.0
side_area = depth * base_perim
volume = base_area * depth
surface_area = base_area + side_area



Note: we get the5because the user selectedcircle. That selection also gives us the formulae for area and perimeter of the base. Thedepthis derived from the input depth value of 24 inches. This could be either calculated or just use the correspondences in the following table.























Inches

Feet
181.5
242.0
302.5


Border


For the Standard version, the program shall calculate the area of a two-foot wide border around the pond. This calculation should also occurwithinthe Python script. The mathematics of calculating the area of the path is left as an exercise for the student. They can be calculated using simple plane geometric figures.

Hint: It's probably easiest to calculate the border by subtracting the top of the pond from a larger solid.



  • Square:



  • Circle:



  • Rectangle:



  • Oval:



  • L:




Sample runs, Standard version


The user input is shown in blue bold text.



Fish ponds are available in the following shapes:
circle, square, rectangle, oval, L
Please select the shape for your fish pond:square

The volume of your fish pond is 50.000 cubic feet.
The surface area of your fish pond is 65.000 square feet.
The area of the border is 56.000 square feet.



The user input is shown in blue bold text.



Fish ponds are available in the following shapes:
circle, square, rectangle, oval, L
Please select the shape for your fish pond:circle

The volume of your fish pond is 39.270 cubic feet.
The surface area of your fish pond is 51.051 square feet.
The area of the border is 43.982 square feet.



The expected values for the volume and surface area are given in the Minimal portion of this write-up. If the calculated values do not agree with the values listed above, the functionality score will not be greater than the minimal score. (It could be less if the values are not reported with three places after the decimal point.)


Challenge version (extra-credit)


For the Challenge version there are two enhancements over the Standard version:



  • The script will handle all three possible depths, 18 inches, 24 inches, and 30 inches.

  • Input validation.


Depth


For the Challenge version, the program shall also support different depths for the pools: 18, 24, or 30 inches. So, the program is going to have to ask the user for the depth of the pool, in addition to the pool shape.


Sample run, Challenge version



Fish ponds are available in the following shapes:
circle, square, rectangle, oval, L
Please select the shape for your fish pond:square

Fish ponds are available in the following depths:
18, 24, 30
Please select the depth for your fish pond:18

The volume of your fish pond is 37.500 cubic feet.
The surface area of your fish pond is 55.000 square feet.
The area of the border is 56.000 square feet.



Input validation


In the minimal and standard versions of the assignment, unrecognized input values for the shape (or depth, for the standard version) of the pond can cause the program to fail to output anything, or even to crash. This is not really very user friendly. In fact, when you ask the user for information, you (as the programmer) have to assume that the user will make a mistake. So, we want to build the program to respond appropriately when the user's input in not one of the expected values. This goes by many names, two of the most common are:fault toleranceandinput validation.The namefault toleranceindicates that the program should be tolerant (resilient) to errors (from the user, in this case); the nameinput validationindicates that the program checks to make sure that the input received from the user is valid before proceeding into processing with those values.


The challenge version handles user input errors "more gracefully". That is, it shall end the program by reporting the error to the user. When an error is encountered,the program should not ask the user for an updated value. (We'll be doing that kind of work later.)


Sample runs, input validation



Fish ponds are available in the following shapes:
circle, square, rectangle, oval, L
Please select the shape for your fish pond:squar

Fish ponds are available in the following depths:
18, 24, 30
Please select the depth for your fish pond:24

Unrecognized shape "squar".
Please run the program again.



It doesn't have to ask both questions.



Fish ponds are available in the following shapes:
circle, square, rectangle, oval, L
Please select the shape for your fish pond:squar





Unrecognized shape "squar".
Please run the program again.



It should also give an error message for unrecognized depth values.



Fish ponds are available in the following shapes:
circle, square, rectangle, oval, L
Please select the shape for your fish pond:square

Fish ponds are available in the following depths:
18, 24, 30
Please select the depth for your fish pond:23

Unrecognized depth "23".
Please run the program again.



This input validation for depth should handle non-integer input values. The program shouldn't crash for non-integer depth values.



Fish ponds are available in the following shapes:
circle, square, rectangle, oval, L
Please select the shape for your fish pond:square

Fish ponds are available in the following depths:
18, 24, 30
Please select the depth for your fish pond:2e

Unrecognized depth "2e".
Please run the program again.






Jan 21, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here