-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBankBalance.java
30 lines (29 loc) · 974 Bytes
/
BankBalance.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
import java.util.Scanner;
public class BankBalance
{
public static void main(String[] args)
{
double balance;
int response;
int year = 1;
final double INT_RATE = 0.03;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter initial bank balance > ");
balance = keyboard.nextDouble();
keyboard.nextLine();
System.out.println("Do you want to see next year's balance?");
System.out.print("Enter 1 for yes ");
System.out.print(" or any other number for no >> ");
response = keyboard.nextInt();
while(response == 1)
{
balance = balance + balance * INT_RATE;
System.out.println("After year " + year + " at " + INT_RATE + " interest rate, balance is $" + balance);
year = year + 1;
System.out.print("Do you want to see the balance " +
"\nat the end of another year?");
System.out.print(" or any other number for no >> ");
response = keyboard.nextInt();
}
}
}