!/usr/bin/env python
coding:utf-8
计算结果百位500向下取整,(0-499取000,500-999取500)
import math
calc_Amount = float(input("输入所有可需金额:"))
act_Amount = calc_Amount
if calc_Amount > 0:
value2 = calc_Amount / 1000
value3 = math.floor(value2)
if (value2 - value3) < 0.5 and (value2 - value3) >= 0:
result = value31000
else:
result = (value3+0.5)1000
print(result)
else:
print(str(calc_Amount)+"数字有问题")
Java编写
package org.learn.JavaLearn;
import java.lang.Math;
public class CalcBTXYApp {
public static void main(String[] agrs){
// calc500round(11999.00);
// thirdjinwei(111.0922);
// applyrepayeach(5000,0.007,3);
CalcBTXYApp calcBTXYApp =new CalcBTXYApp();
System.out.println(calcBTXYApp.applyrepayeach(5000,0.007,3));
}
public double applyrepayeach(double applyAmount,double fee,int qishu){
double Amount =applyAmount;
double repayeach;
repayeach = thirdjinwei(Amount/qishu) + thirdjinwei(Amount*fee);
// System.out.println("借款申请页每月应还:"+repayeach);
return repayeach;
}
public double newRepayeach(double creditAmount,double baoxianfee,double fee,int qishu){
double rebaoxian ;
double newLoanAmount;
double newbaoxian;
double Amount;
double nowrepayeach;
rebaoxian =Math.floor(creditAmount*baoxianfee);
newLoanAmount = calc500round(creditAmount-rebaoxian);
newbaoxian = Math.floor(newLoanAmount*baoxianfee);
Amount = newLoanAmount+newbaoxian;
nowrepayeach =thirdjinwei(thirdjinwei(Amount/qishu)+thirdjinwei(Amount*fee));
// return Amount;
return nowrepayeach;
}
public double thirdjinwei(double amount){
amount = amount*1000;
amount = Math.floor(amount);
amount = amount/10;
amount = Math.ceil(amount);
amount = amount/100;
// System.out.println(amount);
return amount;
}
public double calc500round(double calc_Amount){
double act_Amount;
double value2;
double value3;
double result=0;
act_Amount = calc_Amount;
if (calc_Amount>0){
value2 = calc_Amount/1000;
value3 = Math.floor(value2);
if ((value2-value3)<0.5 &&(value2-value3)>=0){
result = value3*1000;
}else {
result = (value3+0.5)*1000;
}
// System.out.println(result);
//return result;
}else {
System.out.println(calc_Amount+"金额数字有问题");
}
return result;
}
}