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

A+ Finance Company guarantees a 2% monthly compounded return on your investment.

ID: 3865110 • Letter: A

Question

A+ Finance Company guarantees a 2% monthly compounded return on your investment. You want to see how long it takes to reach a total of $10,000,000 (10 million dollars) in investment plus return. Write a program that allows the user to enter a continuous monthly investment (Example - $500 every month) or ($1,000 every month). The Java program should call a recursive method ( a method that calls itself) that returns and displays the total months needed to reach the $10,000,000 goal. Example - At the 2% compounded monthly rate, and a $1,000 monthly investment, the first month should yield $1,020.00, the second month $2,060.40, the third month $3,121.61, the fourth month $4,204.04, etc. Display how many total months it takes the user to reach the million dollar goal. Remember, the user should be able to input the monthly continuing investment. The rate is always 2% and compounded monthly.

Explanation / Answer

import java.util.Scanner;

public class InvestPeriod {
   static double finalReturn = 10000000.0;
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       System.out.println("Enter your monthly Investment amount :");
       double monthyInvst = sc.nextDouble();
       int months = getTime(monthyInvst);
       int years = months/12;
       months = months%12;
       System.out.println("Time to reach Goal : "+years+" Years, "+months+" Months");
       sc.close();

   }
   //Recursive method to calculate return time
   public static int getTime(double amount){
       double compound = amount + (amount/100.0d)*2.0d;
       if(compound>finalReturn)
           return 1;
       return 1 + getTime(compound);
   }
}

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