Advertisement
PadmaJS

Exercise 2.13

Sep 29th, 2022
1,059
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.49 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Exercise2_13 {
  4.   public static void main(String[] args) {
  5.     Scanner in = new Scanner(System.in);
  6.     System.out.print("Enter monthly saving amount: ");
  7.     double monthlySavings = in.nextDouble();
  8.     double total = 0;
  9.     double monthlyRate = 0.00417;
  10.  
  11.     for (int i = 0; i < 6; i++) {
  12.       total = (monthlySavings + total) * (1 + monthlyRate);
  13.     }
  14.     System.out.printf("After the sixth month, the account value is $%.2f", total);
  15.   }
  16. }
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement