-
Notifications
You must be signed in to change notification settings - Fork 0
/
BankBalanceByRateAndYear.java
31 lines (31 loc) · 1.02 KB
/
BankBalanceByRateAndYear.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.Scanner;
public class BankBalanceByRateAndYear
{
public static void main(String[] args)
{
double initialBalance;
double balance;
int year;
double interest;
final double LOW = 0.02;
final double HIGH = 0.05;
final double INCREMENT = 0.01;
final int MAX_YEAR = 4;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter initial bank balance > ");
initialBalance = keyboard.nextDouble();
keyboard.nextLine();
for(interest = LOW; interest <= HIGH; interest += INCREMENT)
{
balance = initialBalance;
System.out.println("\nWith an initial balance of $" +
balance + " at an interest rate of " + interest);
for(year = 1; year <= MAX_YEAR; ++ year)
{
balance = balance + balance * interest;
System.out.println("After year " + year +
" balance is $" + balance);
}
}
}
}