Skip to content

Commit 14a9bfd

Browse files
committed
Fix budget input validation
1 parent 5a7cb0c commit 14a9bfd

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

‎financalc.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
# Simple Financial Calculation
3+
4+
budget = input("Enter your budget: ")
5+
6+
try:
7+
budget_value = float(budget.replace(",", "").replace("₹", "").strip())
8+
9+
if budget_value <= 0:
10+
print("\nBudget must be greater than zero.")
11+
12+
else:
13+
inventory = budget_value * 0.40
14+
operations = budget_value * 0.30
15+
marketing = budget_value * 0.10
16+
emergency = budget_value * 0.20
17+
18+
print("\nSUGGESTED BUDGET ALLOCATION")
19+
print("-" * 40)
20+
print(f"Inventory / Product: ₹{inventory:,.2f}")
21+
print(f"Operations: ₹{operations:,.2f}")
22+
print(f"Marketing: ₹{marketing:,.2f}")
23+
print(f"Emergency Reserve: ₹{emergency:,.2f}")
24+
print("-" * 40)
25+
print(f"Total Budget: ₹{budget_value:,.2f}")
26+
27+
except ValueError:
28+
print("\nInvalid budget. Please enter a valid number.")

0 commit comments

Comments
 (0)