Created
September 1, 2012 13:41
-
-
Save danielpclark/3573438 to your computer and use it in GitHub Desktop.
Calculate how much a budget truck rental will cost you.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# | |
# | |
# Budget Rental Calculator * * * * * | |
# `Originl` Author: Daniel P. Clark <webmaster@6ftdan.com> | |
# Written : May 6th, 2011 | |
# | |
def ifth(mystr = "",myfl = 0.0): # my own if then returning a float | |
if mystr == "": | |
return myfl | |
else: | |
return float(mystr) | |
print "-"*60 | |
print " * * * * * Budget Rental Calculator * * * * * " | |
print "-"*60 | |
dailyrental = raw_input("What is your cost per day for the rental? ($35.99) $") | |
dailyrental = ifth (dailyrental, 35.99) | |
dailyinsurance = raw_input("Insurance cost is daily. What is your rate? ($29.99) $") | |
dailyinsurance = ifth (dailyinsurance, 29.99) | |
mileagerate = raw_input("What is your mileage rate? (rate per mile) (0.24) $") | |
mileagerate = ifth (mileagerate, 0.24) | |
mileage = raw_input("Mileage estimate or actual number: (224) :") | |
mileage = ifth(mileage, 224) | |
print "24 hour strict daily rate! If you pass the hour you get billed another day." | |
days = raw_input("Rental for how many days? (2) :") | |
days = ifth(days, 2) | |
print " * * * * * NOTICE!!! * * * * * " | |
print "The sate of Virginia double taxes rental trucks." | |
print " 5% + 5% = 10% " | |
statetax = raw_input("What is your tax rate in decimal for? e.g. 10% = (0.10) :") | |
statetax = ifth(statetax, 0.1) | |
print " * Cost recovery fee of $3 per day." | |
costrecovery = 3 | |
print " * Daily energy tax of 13 cents per day." | |
energytax = 0.13 | |
gasprice = raw_input("What did you pay for gas per gallon? ($3.859) $") | |
gasprice = ifth(gasprice, 3.859) | |
gasgallons = raw_input("How many gallons of gas did you put in? (20.736) :") | |
gasgallons = ifth(gasgallons, 20.736) | |
print "-"*60 | |
rentaltotal = (dailyrental + dailyinsurance + costrecovery + energytax) * days + mileagerate * mileage | |
rentaltotal += rentaltotal*statetax | |
print "Rental total comes to: $%.02f" % rentaltotal | |
gascost = gasprice * gasgallons | |
print "Fuel cost you: $%.02f" % gascost | |
print "Total travel cost with this rental comes to: $%.02f" % (rentaltotal + gascost) | |
print "Miles to the gallon came to:", int(mileage/gasgallons), "miles per gallon." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment