-1

私は初心者の PYTHON プログラマーで、いくつかのコードを書いていますが、うまくいきません...エラーを見つけて修正するのを手伝ってくれませんか?

これまでの私のコードは次のとおりです。

balance=int(raw_input("Enter the outstanding balance on your credit card: "))
annualInterestRate=float(raw_input("Enter the annual credit card interest rate as a decimal: "))
monthlyPaymentRate=float(raw_input("Enter the monthly payment rate as a decimal"))

monthInterestRate = annualInterestRate / 12
monthlyPayment = monthlyPaymentRate*balance
newBalance= (balance-monthlyPayment) * (1 + monthInterestRate) #newBalance is updated balance
month=0

while month<12:
    month += 1
    monthlyPayment = (monthlyPaymentRate*balance)
    newBalance=(balance-monthlyPayment)*(1 + monthInterestRate)
    newBalance = balance
    print("Month: " + str(month))
    print("Minimum monthly payment: " + str(monthlyPayment))
    print("Remaining balance: " + str(newBalance))
4

2 に答える 2

1

推測では、問題はnewBalance = balance、直前の行で実行し続けた計算を破棄し、元の残高に置き換えることです。しかし、どのような「エラー」が表示されているかを言わないと、確信が持てません。

于 2012-10-16T03:19:35.487 に答える
0
balance = int(raw_input("Enter the outstanding balance on your credit card: "))
annualInterestRate = float(raw_input("Enter the annual credit card interest rate as a decimal: "))
monthlyPaymentRate = float(raw_input("Enter the monthly payment rate as a decimal: "))
month = 0

while month<12:
    monthlyPayment = (monthlyPaymentRate)*(balance)
    unpaidBalance = (balance)-(monthlyPayment)
    interest = ((annualInterestRate)/(12.0)) *(unpaidBalance)
    updatedBalance = (unpaidBalance)+(interest)
    month +=1
    balance = updatedBalance
    print ('Month: '+ str(month))
    print ('Minimum monthly payment:' + str(round(monthlyPayment,2)))
    print ('Remaining Balance after one year: ' + str(round(updatedBalance,2)))
于 2015-01-21T17:59:57.980 に答える