1+ """
2+
3+ Developer: Kerem Can Belli
4+ Project: Python Starter Algorithms and CLI Applications
5+ Subproject: Financial Calculator
6+ Description: Updated English version with structured comments
7+ Last Review: November 2025
8+
9+ """
10+
11+ ##########################################################################
12+
13+ """
14+
15+ Project's main menu:
16+
17+ * It is questioned what users want which option.
18+ * Input is validated using try-except blocks to handle non-integer input.
19+
20+ """
21+
22+ print ("\n --- FUNDAMENTAL FINANCIAL CALCULATOR ---" )
23+ while True :
24+ try :
25+ user_choice_input = input ("Press 1 for basic interest calculator: \n " \
26+ "Press 2 for installment calculator: \n " \
27+ "Press 3 for VAT calculator: \n " \
28+ "Press 4 to quit: " ) # It is questioned what users want which option.
29+ user_choice = int (user_choice_input ) # user_choice_input is converted to integer.
30+ if user_choice not in [1 ,2 ,3 ,4 ]:
31+ print ("Enter one of the numbers that you see on the screen." )
32+ continue
33+ break
34+ except ValueError :
35+ print ("Please input an integer." )
36+
37+ ##########################################################################
38+
39+ def check_number (prompt ,type ):
40+
41+ """
42+
43+ Validates user input to ensure it is a positive number (float or int).
44+
45+ Args:
46+ prompt (str): The message displayed to the user.
47+ tip (type): The desired data type (e.g., int, float).
48+
49+ Returns:
50+ The validated input value in the specified type.
51+
52+ """
53+
54+ while True :
55+ try :
56+ value = type (input (prompt ))
57+ if value <= 0 :
58+ print ("Please input a positive rational number." ) # Rational number is checked whether it is positive or not.
59+ continue
60+ return value
61+ except ValueError :
62+ print ("Please input a rational number." )
63+
64+ ##########################################################################
65+
66+ def basic_interest_calculator ():
67+
68+ """
69+
70+ basic_interest_calculator function:
71+
72+ * Base money, interest rate and time values are wanted from users in this function.
73+ * Interest difference and final amount are calculated and printed.
74+
75+ """
76+
77+ print ("\n --- BASIC INTEREST CALCULATOR ---" )
78+ # Base money, interest rate and time values are wanted from users in this function.
79+ base_money = check_number ("Enter your base money amount (TL): " , int )
80+ interest_rate = check_number ("Enter your annual interest rate (%): " , float )
81+ time = check_number ("Enter time (month): " , int )
82+
83+ # Interest difference and final amount are calculated and printed.
84+ interest_difference = base_money * (interest_rate / 100 ) * (time / 12 )
85+ final_amount = interest_difference + base_money
86+
87+ print ("\n --- RESULT ---" )
88+ print (f"Interest difference: { interest_difference } TL" )
89+ print (f"Total amount: { final_amount } TL" )
90+
91+ ##########################################################################
92+
93+ def installment_calculator ():
94+
95+ """
96+
97+ installment_calculator function:
98+
99+ * Credit amount, interest rate and time are wanted from users in this function
100+ * User's monthly credit installment is calculated with using special formula and showed the users.
101+
102+ """
103+
104+ print ("\n --- INSTALLMENT CALCULATOR ---" )
105+
106+ # Credit amount, interest rate and time are wanted from users in this function
107+ credit_amount = check_number ("Enter your credit amount: " , int )
108+ interest_rate = check_number ("Enter your annual interest rate (%): " , float )
109+ time = check_number ("Enter time (month): " , int )
110+
111+ # User's monthly credit installment is calculated with using special formula and showed the users.
112+ interest_rate = interest_rate / (100 * 12 )
113+ formula_top_section = interest_rate * ((1 + interest_rate )** time )
114+ formula_bottom_section = ((1 + interest_rate )** time ) - 1
115+ formula = formula_top_section / formula_bottom_section
116+ monthly_installment = credit_amount * formula
117+
118+ print ("\n --- RESULT ---" )
119+ print (f"Your monthly credit installment: { monthly_installment } TL" )
120+
121+ ##########################################################################
122+
123+ def vat_calculator ():
124+
125+ """
126+
127+ vat_calculator function:
128+
129+ * Total amount and vat values are wanted from users
130+ * It is questioned that users want to remove vat value from total amount or add.
131+ * Input is validated using try-except blocks to handle non-integer input.
132+ * The result is displayed based on the user's preference.
133+
134+ """
135+
136+ print ("\n --- VAT CALCULATOR ---" )
137+
138+ # Total amount and vat values are wanted from users
139+ total_amount = check_number ("Enter the total amount: " , int )
140+ vat = check_number ("Enter your vat rate (%): " , int )
141+ while True :
142+ try :
143+ decision_input = input ("Press 1 to add VAT\n "
144+ "Press 2 to remove VAT: " ) # It is questioned that users want to remove vat value from total amount or add.
145+ decision = int (decision_input )
146+ if decision not in [1 ,2 ]:
147+ print ("Please enter 1 or 2." ) # Input is validated using try-except blocks to handle non-integer input.
148+ continue
149+ break
150+ except ValueError :
151+ print ("Please input an integer." )
152+ if decision == 1 :
153+ vat_amount = total_amount * (vat / 100 )
154+ added_amount = total_amount + vat_amount
155+
156+ print ("\n --- RESULT ---" )
157+ # The result is displayed based on the user's preference.
158+ print (f"Price with VAT added: { added_amount } TL" )
159+ else :
160+ vat_amount = total_amount * (vat / 100 )
161+ removed_amount = total_amount - vat_amount
162+
163+ print ("\n --- RESULT ---" )
164+ # The result is displayed based on the user's preference.
165+ print (f"Price with VAT removed: { removed_amount } TL" )
166+
167+ ##########################################################################
168+
169+ if user_choice == 1 :
170+ basic_interest_calculator ()
171+ elif user_choice == 2 :
172+ installment_calculator ()
173+ elif user_choice == 3 :
174+ vat_calculator ()
175+ else :
176+ exit ()
0 commit comments