1 Star 0 Fork 2

谢继业/teamdemo

forked from 贾沈杰/teamdemo 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
CDTable.java 1.04 KB
一键复制 编辑 原始数据 按行查看 历史
root 提交于 2020-05-23 13:18 . 作业
import java.util.Scanner;
/**
A program that reads in an interest rate and creates a table of
future values of a one-thousand dollar certificate of deposit
for that interest rate and different numbers of years.
All variables should be of type double, except for the number of years.
*/
public class CDTable
{
public static void main (String[] args)
{
// Display prompt for interest rate
System.out.print("Please enter the rate of interest: ");
// Read interest rate
Scanner in = new Scanner(System.in);
double rate = in.nextDouble();
int years = 0;
double presentVal = 1000.00;
System.out.printf("%2d %7.2f\n", years, presentVal);
double finalVal = 0.0;
for (years = 5; years <= 25; years += 5) {
finalVal = presentVal * Math.pow( (1 + rate / 100.00), (double)years );
System.out.printf("%2d %7.2f\n", years, finalVal);
}
// Print out different values for different years
// Your work here
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/xjyng/teamdemo.git
git@gitee.com:xjyng/teamdemo.git
xjyng
teamdemo
teamdemo
master

搜索帮助