forked from logenkain/cig-cost
72 lines
1.6 KiB
Python
72 lines
1.6 KiB
Python
#!/usr/bin/python3
|
|
#user input dollars
|
|
#user input number of packs
|
|
#output day, week, month year costs
|
|
import os
|
|
import math
|
|
|
|
cost = None
|
|
packs = None
|
|
|
|
|
|
def calcHours(tempCost):
|
|
return format(float(tempCost)/wages, '.2f')
|
|
|
|
|
|
|
|
while True:
|
|
os.system('clear')
|
|
try:
|
|
cost = float(input("How much does a pack cost? "))
|
|
except ValueError:
|
|
print("Please only type numbers")
|
|
input("Press 'enter' to continue: ")
|
|
continue
|
|
|
|
try:
|
|
packs = float(input("How many packs do you smoke a day? "))
|
|
except ValueError:
|
|
print("Please only type numbers")
|
|
input("Press 'enter' to continue: ")
|
|
continue
|
|
|
|
try:
|
|
wages = float(input("What is your hourly wage? "))
|
|
except ValueError:
|
|
print("Please only type numbers")
|
|
input("Press 'enter' to continue: ")
|
|
continue
|
|
|
|
os.system('clear')
|
|
break
|
|
|
|
print("Your cigarettes cost $" + format(cost/20, '.2f'), "each")
|
|
|
|
print()
|
|
print("You smoke: ")
|
|
print(math.ceil(20 * packs), "per day")
|
|
print(math.ceil(20 * packs * 7), "per week")
|
|
print(math.ceil((20 * packs * 365)/12), "per month")
|
|
print(math.ceil(20 * packs * 365), "per year")
|
|
|
|
print()
|
|
|
|
print("This costs you: ")
|
|
|
|
tempCost = format(cost * packs, '.2f')
|
|
tempHours = calcHours(tempCost)
|
|
print("$" + tempCost, "and", tempHours, "hours per day")
|
|
|
|
tempCost = format(cost * packs * 7, '.2f')
|
|
tempHours = calcHours(tempCost)
|
|
print("$" + tempCost, "and", tempHours, "hours per week")
|
|
|
|
tempCost = format((cost * packs * 365)/12, '.2f')
|
|
tempHours = calcHours(tempCost)
|
|
print("$" + tempCost, "and", tempHours, "hours per month")
|
|
|
|
tempCost = format(cost * packs * 365, '.2f')
|
|
tempHours = calcHours(tempCost)
|
|
print("$" + tempCost, "and", tempHours, "hours per year")
|
|
|