├── LICENSE ├── MaterialsCostCalculatorScript.py └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Ryan Reyes (github.com/TechProofreader) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MaterialsCostCalculatorScript.py: -------------------------------------------------------------------------------- 1 | # Author: Ryan Reyes (github.com/TechProofreader) 2 | # Program Name: Materials Calculator Script 3 | # Version: 1.0 4 | 5 | import time 6 | 7 | print("Note: for all questions, please only input numbers. Leave out any symbols such as $, %, etc.") 8 | 9 | time.sleep(2) 10 | 11 | print("What are the dimensions of your project?") 12 | 13 | def errorFunction(lit): # the 'lit' call tells the computer to just use the literal string from the input 14 | while True: 15 | try: 16 | x = float(input(lit )) # an if statement is not needed here because if the program 17 | break # can't convert the input to float, it will throw errors 18 | except ValueError: 19 | print("Please only enter numbers.") 20 | return x 21 | 22 | length=errorFunction("Length: ") # the 'lit' call will literally pass through whatever the user 23 | # inputs here and all other places where user input is passed 24 | print("by") # through the errorFunction() 25 | 26 | width=errorFunction("Width: ") 27 | 28 | area = abs(round(length*width, 2)) 29 | 30 | print("The total area of your project is", str(area)+".") 31 | 32 | costPerSqFt = abs(errorFunction('What is the cost of the materials you plan on using (per sq-ft, for example)?:' )) 33 | 34 | beforeTaxCost = round(costPerSqFt*area, 2) 35 | 36 | print("The total cost of materials before tax is:", str(beforeTaxCost)+".") 37 | time.sleep(1) 38 | print("If you know your sales tax rate and would also like to know the total cost of materials plus tax, please type \'yes\', otherwise please type \'no\'.") 39 | 40 | while True: 41 | try: 42 | list = ["yes", "no"] 43 | salesTaxYesNo = input() 44 | salesTaxYesNo = salesTaxYesNo.lower() 45 | if salesTaxYesNo not in list: 46 | raise ValueError 47 | break 48 | except ValueError: 49 | print("Please only type \'yes\' or \'no\'.") 50 | 51 | if salesTaxYesNo == "yes": 52 | 53 | while True: 54 | try: 55 | tax = abs(float(input("Please input your sales tax in percentage form without the \'%\' symbol:"))) 56 | if tax is float(tax): 57 | taxToPercentage = (tax / 100) 58 | print("The total cost of your project is:", str((round(costPerSqFt*area*(1+(taxToPercentage)), 2)))+".") 59 | print("Thank You for using my materials cost calculator tool, good luck with your project!") 60 | if tax is not float(tax): 61 | raise ValueError 62 | break 63 | except ValueError: 64 | print("Please only enter numbers") 65 | 66 | elif salesTaxYesNo == "no": 67 | print("Thank You for using my materials cost calculator tool, good luck with your project!") 68 | 69 | exit 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Materials-Cost-Calculator 2 | 3 | _Note: This is a Beginner Level program that you can use to further your Python knowledge by first learning how the base program works, and then extending the program with your own additions._ 4 | 5 | This is a script that I wrote with Python 3.7.3 that takes user inputs related to a construction/renovation project and outputs a total cost of materials for said project. The output is based on the user's inputs related to the length and width of the project, the cost-per-unit of the project (think dollars per square-foot, for example), and sales tax if the user knows their local sales tax rate and would like for the sales tax to be included in the total cost of their project. 6 | 7 | I left out all currency designations because they are unnecessary for an input/output computation that is based solely on math. I also kept the calculations to 2-D space because the most common type of calculation related to construction/renovation projects pertains to flooring plans, as walls (which would constitute the 3-D space) are frequently calculated separately. 8 | 9 | The goal of this script is to shorten the time it takes to calculate cost estimates for construction/renovation projects, especially related to flooring. Rather than mashing the buttons on a calculator all day long and converting tax rates, you can simply answer the prompts of this script and it does all of the work for you. 10 | --------------------------------------------------------------------------------