📄 growth.java
字号:
//Copyright (c) 1998, Arthur Gittleman
//This example is provided WITHOUT ANY WARRANTY either expressed or implied.
/*
* Input: Rate, a double value giving the yearly percent interest rate
* Balance, a double value giving the amount deposited
* Years, an int value giving the time period for the deposit
*
* Output : Amount, the total amount in the account at the end of the
* time period.
*/
import iopack.Io;
public class Growth {
public static void main(String [] args) {
double rate; // yearly percent interest rate
double balance; // amount on deposit
int years; // time period of the deposit
double interest; // interest earned in current year
rate = Io.readDouble("Enter the percent interest rate");
balance = Io.readDouble("Enter the initial balance");
years = Io.readInt("Enter the time period for the deposit");
for (int i = 1; i <= years; i++) {
interest = balance * rate/100;
balance += interest;
}
System.out.print ("The balance after " + years + " years is ");
Io.println$(balance);
Io.readString("Press any key to exit"); // Added for IDE use
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -