zoukankan      html  css  js  c++  java
  • 每日总结

     代码:

    import com.sun.tools.javac.Main;

    import java.math.BigDecimal;

    public class test {
        public static void main(String[] args) {
            float xm[][]={
                    {-100000,10000,10000,10000,20000,100000},
                    {-1000000,200000,200000,200000,200000,300000},
                    {-100000,30000,30000,30000,30000,30000},
                    {-120000,30000,30000,30000,30000,75000}
            };
            float r1 = (float) 0.08;
            float r2 = (float) 0.12;
            float num1[] = new float[6];
            float num2[] = new float[6];
            float sum1[] = {0,0,0,0};
            float sum2[] = {0,0,0,0};
            System.out.println("贴现率为:"+r1);
            for (int i=0;i<6;i++){
                num1[i] = Float.parseFloat(String.format("%.4f",(float) (1.0/Math.pow((1+r1),i))));
                System.out.println(""+i+"年的贴现因子:" +num1[i]);
            }
            for (int i=0;i<4;i++){
                for (int j=0;j<6;j++){
                    sum1[i] += xm[i][j] * num1[j];
                }
                sum1[i] = Math.round(sum1[i]);
                System.out.println("项目"+i+"NPV为:"+ sum1[i]);
            }
            System.out.println("-----------------------------------------------------------------");
            System.out.println("贴现率为:"+r2);
            for (int i=0;i<6;i++){
                num2[i] = Float.parseFloat(String.format("%.4f",(float) (1.0/Math.pow((1+r2),i))));
                System.out.println(""+i+"年的贴现因子:" +num2[i]);
            }
            for (int i=0;i<4;i++){
                for (int j=0;j<6;j++){
                    sum2[i] += xm[i][j] * num2[j];
                }
                sum2[i] = Math.round(sum2[i]);
                System.out.println("项目"+i+"NPV为:"+ sum2[i]);
            }
        }
    }

    截图:

  • 相关阅读:
    怎么样从多列的DataTable里取需要的几列
    .net core 生成二维码
    sql server2012卸载
    github实用的搜索小技巧
    c# 中的索引
    IOC
    Python基础-while
    Python基础-判断闰年
    Python基础-while奇数和
    Python基础-奇偶判断调用函数
  • 原文地址:https://www.cnblogs.com/lijiawei1-2-3/p/14505707.html
Copyright © 2011-2022 走看看