Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void calcInterest() {
- double balance;
- double balance1;
- double balance2;
- double balance3;
- double rate;
- int interest;
- Scanner input = new Scanner(System.in);
- System.out.println("Enter your initial balance: ");
- balance = input.nextDouble();
- System.out.println("What is the percentage of the yearly rate of interest? ");
- interest = input.nextInt();
- rate = (interest / 100.0);
- balance1 = balance + (balance * rate);
- balance2 = balance1 + (balance1 * rate);
- balance3 = balance2 + (balance2 * rate);
- System.out.println("Balance after 1 year: " + balance1);
- System.out.println("Balance after 2 years: " + balance2);
- System.out.println("Balance after 3 years: " + balance3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement