COS 100: Introduction to Programming
Fall 2019
HW Project 02: Counting the cost
Due: 09/25 Wed 10pm
For which of you, intending to build a tower, does not sit down first and count the cost, whether he has enough to finish it—lest, after he has laid the foundation, and is not able to finish, all who see it begin to mock him, saying, ‘This man began to build and was not able to finish’?
Luke 14:28–30
Project goal
You have been tasked with building a cylindrical grain silo. The main section of the silo is a cylinder, and the top is a hemisphere (half of a sphere).Project specification
-
Name your project source code
silo.py
. - Prompt the user to provide a diameter for the base of the silo in meters.
- Prompt the user for the height of the cylinder part of the silo in meters.
- Assume that the dome part is a hemisphere with a radius equal to that of the base of the silo.
- Tell the user what the footprint area covered by such a silo would be.
- Tell the user what the total volume inside the silo would be.
- Tell the user how much paint coverage would be needed to cover the entire outside of the silo (not including the bottom since that's in contact with the ground).
- Use proper units for each statement to the user.
- Include your name in the comments at the top of your source code. (Mimic the format from the previous homework.)
Sample run
Please provide the diameter of the silo in meters: 23.7 Please provide the height of the silo in meters: 117.2 With a diameter of 23.7 meters, and a height of 117.2 meters, the silo will cover a footprint area of 441.1502943987127 square meters, a volume of 55187.901829278955 cubic meters, and require 9608.514007114578 square meters of paint.
Suggested order of development
It is best to develop programs incrementally, testing small bits and pieces as you go. Here is a suggested order of development based on years of experience.- Prompt the user and collect input values.
- Print out the part of the report that just repeats the user's inputs back to them.
- One at a time, calculate and add to the report:
- The footprint area
- The volume
- The surface area that needs to be painted
Notes and hints
- Some useful formulae about the surface area and volume of a sphere.
- Note that we are working with a hemisphere, which is half of a sphere.
-
If you need to use π in Python, you would add a line
import math
at the top of your program. Then any time you need the value of π you can usemath.pi
. -
In Python and most other languages,
number^2
isn't an exponent the way you might expect. Look back in your notes to see how to square numbers. -
Like the last project, please submit only your
.py
file to Moodle. Follow this instruction for future projects; this requirement will not be repeated again. - The TA will not use the sample values above to grade your project, so make sure you can handle other inputs.
- You can assume that the user will provide a valid floating point number as input. We'll discuss invalid user input later in the term.
Start early, have fun, and discuss questions on Moodle.