dkjs1.py
# -*- coding: utf-8 -*-
import android
import os,sys
reload(sys)
sys.setdefaultencoding('utf-8')
droid = android.Android()
# 等额本息 每月还款额计算公式如下:
# =(贷款本金*月利率*(1+月利率)^还款月数)/((1+月利率)^还款月数-1)
def compute1():
rate= droid.fullQueryDetail("editText1").result["text"]
cap = droid.fullQueryDetail("editText2").result["text"]
months= droid.fullQueryDetail("editText3").result["text"]
print rate,cap,months
try:
c = float(cap)
r = float(rate)
m = float(months)
if m >360.0: return
mhk = (c*(r/1200)*(1+r/1200)**m)/((1+r/1200)**m-1)
total = mhk*m
print 'total: %.2f' % (total)
out = "每月还款额: %.2f元\n还款总利息= %.2f元\n" % (mhk,total-c)
droid.fullSetProperty("Text2","text",out)
except:
droid.makeToast('Error: 输入数字有错误')
return
def eventloop():
while True:
event=droid.eventWait().result
if event["name"]=="click":
id=event["data"]["id"]
if id=="button1":
compute1()
if id=="Exit":
return
elif event["name"]=="screen":
if event["data"]=="destroy":
return
layout = """
"""
droid.fullShow(layout)
eventloop()
droid.fullDismiss()