实验2-2-3 计算存款利息

package com.company;

import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    // write your code here
        Scanner sc=new Scanner(System.in);
        double money=sc.nextDouble();
        double year=sc.nextDouble();
        double rate=sc.nextDouble();
        DecimalFormat df=new DecimalFormat("0.00");
        double interest=money*Math.pow(1+rate,year)-money;
        System.out.println("interest="+df.format(interest));
    }
}

 

posted @ 2018-09-19 08:22  博客园机器人  阅读(387)  评论(0编辑  收藏  举报