Mobil ilovalarni ishlab chiqish
Bank uchun kredit kalkulyatorini yaratish
Download 53.06 Kb. Pdf ko'rish
|
Mobil ilovalarni ishlab chiqish
Bank uchun kredit kalkulyatorini yaratish
Quyidagi kodlar, bank uchun kredit kalkulyatorini yaratish uchun Python dasturi sifatida yozilgan. Bu dastur, kredit miqdorini, foiz darajasi va kredit muddatini qabul qilib, kredit to'lovlarini va umumiy to'lov miqdorini hisoblaydi: def calculate_loan_payment(principal, annual_interest_rate, years): monthly_interest_rate = annual_interest_rate / 12 months = years * 12 payment = (principal * monthly_interest_rate) / (1 - (1 + monthly_interest_rate) ** -months) return payment def loan_calculator(): print("Welcome to the Loan Calculator!") print("Please enter the following information:") principal = float(input("Loan amount: ")) annual_interest_rate = float(input("Annual interest rate (as a decimal): ")) years = int(input("Loan duration (in years): ")) monthly_payment = calculate_loan_payment(principal, annual_interest_rate, years) total_payment = monthly_payment * years * 12 print(f"\nMonthly payment: ${monthly_payment:.2f}") print(f"Total payment: ${total_payment:.2f}") loan_calculator() Dastur foydalanuvchi tomonidan kredit miqdori (principal), yillik foiz darajasi (annual_interest_rate) va kredit muddatini (years) so'rab, kredit to'lovlarini hisoblaydi. calculate_loan_payment() funksiyasi, kredit to'lovlarini hisoblash uchun formula ishlatadi va o'tish darajasini oylik hisobga oladi. Natijada, oylik to'lovni topish uchun kredit muddatini oyda ko'paytiradi. loan_calculator() funksiyasi, dastur boshlanishida foydalanuvchini salomlaydi va kredit kalkulyatorini ishlatish uchun kredit miqdori, yillik foiz darajasi va kredit muddatini so'ragan holda calculate_loan_payment() funksiyasini chaqiradi. Dastur natijasida, kiritilgan ma'lumotlar bo'yicha oylik to'lovni va umumiy to'lov miqdorini chiqaradi. Download 53.06 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling