Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the IO module, and no methods other than the main method, write a program

ID: 3807773 • Letter: U

Question

Using the IO module, and no methods other than the main method, write a program in Java with pseudocode for the following:

The user puts some money into a savings account. Each month, they might (or might not) make a deposit into that account. The amount of the deposit can vary from month to month. They will not make any withdrawals. Interest is paid on the account once a month.

Your program should determine how long it will take for the savings account to double in worth from its initial value.

Explanation / Answer

Following is the complete code for the above problem :

import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;
import java.util.Random;
public class SavingsAccount {
   public static void main(String[] args)
   {
       Scanner scan = new Scanner(System.in);
       System.out.println("Enter initial amount in account :");
       double amount = scan.nextDouble(); // initial amount
       System.out.println("Enter interest rate percentage :");
       double interest = scan.nextDouble(); // interest rate for each month
       double requiredMoney = 2*amount; // required target
       int i = 1; // keeps track of months passed
       while(amount<requiredMoney)
       {
           // calculate months by using compound interest
           double a = requiredMoney/amount;
           double b = 1+interest/100;
           double ans = Math.ceil(Math.log(a)/Math.log(b));
          
           System.out.println("Current amount in account after "+i+"months = "+amount);
           System.out.println("It would take " + (int)ans + " more months to double the money");
           System.out.println("Enter total amount to be added in month "+i);
           amount += scan.nextDouble(); // money added this month
           amount = amount*(1+interest/100);
           i++;
       }
       System.out.println("Initial amount doubled in "+i+" months.");
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote