标签:style blog color java 使用 io ar div
import javax.swing.JOptionPane; public class Investment { public static void main(String[] args){ double value; String input = JOptionPane.showInputDialog(null,"请输入投资金额:","对话框",JOptionPane.QUESTION_MESSAGE); String input1 = JOptionPane.showInputDialog(null,"请输入年利率:","对话框",JOptionPane.QUESTION_MESSAGE); String input2 = JOptionPane.showInputDialog(null,"请输入投资年数:","对话框",JOptionPane.QUESTION_MESSAGE); double investmen = Double.parseDouble(input); double rate = Double.parseDouble(input1); double year = Double.parseDouble(input2); value = investmen * (Math.pow((1 + rate / 100),(year))); JOptionPane.showMessageDialog(null, value); } }
读取投资金额,年利率和年数,输出未来投资金额
未来投资金额=投资金额*(1+年利率)年数*12
使用方法Math.pow(a,b)来计算a的b次幂
标签:style blog color java 使用 io ar div
原文地址:http://www.cnblogs.com/Amoxicil/p/3895137.html