def candle_wax_calculator():
print("🕯️ Candle Wax Calculator\n")
try:
# User inputs
num_candles = int(input("Number of candles: "))
container_size = float(input("Container size (oz): "))
fragrance_load = float(input("Fragrance load (%): "))
include_coconut_oil = input("Include coconut oil? (yes/no): ").strip().lower() in ["yes", "y"]
# Calculations
total_fill = num_candles * container_size
fragrance_weight = total_fill * (fragrance_load / 100)
wax_blend_weight = total_fill - fragrance_weight
if include_coconut_oil:
# Function to estimate coconut oil weight numerically
def calculate_coconut_oil_weight(wax_total):
x = 0.0
for _ in range(1000): # converge
coconut_oil_tsp = ((wax_total - x) / 16) * 0.5
x_new = coconut_oil_tsp / 6 # since 1 fl oz = 6 tsp
if abs(x_new - x) < 0.0001:
break
x = x_new
return x
coconut_oil_oz = calculate_coconut_oil_weight(wax_blend_weight)
base_wax_weight = wax_blend_weight - coconut_oil_oz
coconut_oil_tsp = coconut_oil_oz * 6
coconut_oil_grams = coconut_oil_tsp * 4.5 # 1 tsp ≈ 4.5g
else:
base_wax_weight = wax_blend_weight
coconut_oil_oz = coconut_oil_tsp = coconut_oil_grams = 0.0
# Output
print("\n--- Results ---")
print(f"Total Fill Weight: {total_fill:.2f} oz")
print(f"Fragrance Weight: {fragrance_weight:.2f} oz")
print(f"Base Wax Weight: {base_wax_weight:.2f} oz")
if include_coconut_oil:
print("Coconut Oil:")
print(f" • {coconut_oil_tsp:.2f} tsp")
print(f" • {coconut_oil_oz:.2f} fl oz")
print(f" • {coconut_oil_grams:.2f} grams")
else:
print("Coconut Oil: Not Included")
except ValueError:
print("⚠️ Please enter valid numbers only.")
if __name__ == "__main__":
candle_wax_calculator()