Question: Project # 4 2 D & 3 D Geometry Calculator 1 Problem Overview In a geometry class, you are studying interesting formulas for circles, squares,
Project #D & D Geometry Calculator
Problem Overview
In a geometry class, you are studying interesting formulas for circles, squares, spheres, and cubes. You
are writing a program to encode those formulas and generate accurate results.
User Interface
Input
The program asks the user for a size which will be used for radius and side length, depending on the
shape and the unit of measure being used. Example:
Enter size for side and radius:
Enter unit of measure, eg inches: inches
Output
Displays an attractive and aligned report with all the results, as shown below. Note that the numbers here
are merely samples and are intentionally incorrect; you will need to figure out what is right here!
Square Calculations
Perimeter: linear inches
Area: square inches
Cube Calculations
Volume: cubic inches
Surface area: square inches
Circle Calculations
Circumference: linear inches
Area: square inches
Sphere Calculations
Volume: cubic inches
Surface area: square inches
CSC Intro to Programming with Python
Page of
Functions
Call Hierarchy
Function Specifications
Descriptions
Here is a brief description of what each function should do and what file it should live in:
Function Description File
main Consists of a series of function calls and little else projpy
getInput Asks the user for size and unit of measure; returns those projpy
display Prints a header line egSquare Calculations and the results of
calculations for that object eg all corresponding square calculations
Each takes two parameters, a radius or side length depending on the
context and the unit of measure
projpy
square
cube circle
sphere
Calculates and returns the specific results, eg CubeVolume calculates
the volume of a cube with the specified side length. Each takes a single
parameter, radius or side length depending on the context
pgeom.py
Parameters and Return Values
You need to determine the parameters and return values for each function. But here are some rules you
will need to follow in your quest:
There may be no global variables; you must pass data to functions to communicate it
All functions that calculate geometry results must be in a module a separate file called
pgeom.py The main program will need to import that module and use it
The pgeom.py module must use the math modules pi variable. That means pgeom.py will need
to import the math module.
Watch the names of parameters and arguments; they should not always match as the sender and
receiver may interpret the data in slightly different ways. For example, getInput gathers a generic
size from the user, but circleArea clearly wants a circles radius as a parameter.
main
getInput displaySquareResults
squarePerim
squareArea
displayCubeResults
cubeVolume
cubeSurfArea
displayCircleResults
circleCircum
circleArea
displaySphereResults
sphereVolume
sphereSurfArea
projpy
pgeom.py
CSC Intro to Programming with Python
Page of
Calculations
The geometry calculations are standard ones:
Circle: and
Sphere: and
Square: and
Cube: and
Watch your units of measure and display the correct one, eg linear inches are different from square
inches or cubic inches. Think to make sure you have got it right.
Code Specifications
At the bottom of the program you should have a call to main
Include header comments at the top of each file. Include your name, the date, and a brief
description of what the program does.
Include comments for each section saying what is going on in the lines of code below, eg
# define circle functions
Use comments elsewhere as you think they help guide the reader. Do not overdo, though! Not
every line needs a comment; think about describing a block of related code.
Use blank lines to separate sections and provide visual breathing room.
Use descriptive variable names.
You are free to use more advanced techniques in Python if you have the knowledge, including,
but not limited to decision structures, loops, functions, lists, etc. Please limit your use of external
libraries, beyond the math library. If you are wondering if an external library would be acceptable,
ask the professor.
Hints
Use exactly the call hierarchy shown above, eg main calls displaySquareResults which calls
squarePerim and squareArea. Do not chain functions to force execution order.
Carefully consider parameters for each function. Think about what that function ne
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
