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

The purpose of this program is to accept initial investment, target amount and a

ID: 645664 • Letter: T

Question

The purpose of this program is to accept initial investment, target amount and annual interest rate values from the user and from that calculate interest amounts (compounded monthly) for each year, and total balance at the end of each year. You should display the results (year and balance) for each year. Your program should then check if target amount is reached, if it is, it should display a message stating that it has reached the target and display how long it took to get to the target. Otherwise, it would continue with calculations for the following year. Note: You can ignore data validation at this time to keep your code simple. You must put code comments as appropriate. Write the program in Java Programming

Explanation / Answer

import hava.io.*;
import java.util.Scanner;

public class Interest {

   public static void main(String[] args) {
    
      Scanner stdin = new Scanner( System.in );
    
      int year;
      double principal;
      double target;
      double rate;     
      double interest;
    
      System.out.print("Enter year: ");
      year = stdin.nextInt();

      System.out.print("Enter the initial investment: ");
      principal = stdin.nextDouble();

      System.out.print("Enter the target amount: ");
      target = stdin.nextDouble();
    
      System.out.print("Enter the annual interest rate (as a decimal): ");
      rate = stdin.nextDouble();
    
      interest = principal * rate;     
      principal = principal + interest;

      System.out.printf("Year $%1.2d%n", year);    
      System.out.printf("The amount of interest is $%1.2f%n", interest);
      System.out.printf("The value after one year is $%1.2f%n", principal);
      if(principal>= target){System.out.println("It has reached target");}
      else{System.out.printf("Target not reached:So continue to aim target for next year;)}
}

}

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