• #python计算结果百位500向下取整,(0-499取000,500-999取500)


    !/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;
    }

    }

  • 相关阅读:
    如何实现CSS限制字数,超出部份显示省略号
    html禁止手机页面放大缩小
    jQuery 获取屏幕高度、宽度
    谷歌api 二维码生成 实例
    java.security.NoSuchAlgorithmException: Cannot find any provider supporting RSA
    eclipse安装阿里开发规范
    tomcat下配置http和https
    linux安装redis
    修改java配置文件
    Linux下安装Mysql
  • 原文地址:https://www.cnblogs.com/ITniu/p/9089487.html
Copyright © 2020-2023  润新知