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

For this question, write a program in Java. Walkthrough: Prompt the user to ente

ID: 665154 • Letter: F

Question

For this question, write a program in Java.

Walkthrough:

Prompt the user to enter an investment amount and store it as a double variable called investmentAmount. Prompt the user to enter a yearly interest rate and store it as a double called annualInterestRate. Output table headers "Years" and "Future Value". Format "Years" as a string, left aligned, in a column of at least 5 chars. Format "Future Value" as a string, right aligned, in a column of at least 20 chars.

Create a for loop that loops 30 times. In the for loop create a double called futureValue and assign it the value of futureInvestmentValue. futireInvestmentValue will pass investmentAmount, annualInterestRate / 1200 and i.

Print i and futureValue in a table with i formatted as a string, left aligned, in a column of at least 5 chars and with futureValue formatted as a string, right aligned, in a column of at least 20 chars.

Create a method called futureInvestmentValue of type double that takes three inputs: double investmentAmount, double monthlyInterestRate, and int years. The function will return investmentAmount times 1 + monthlyInterestRate to the power of years times 12.

Explanation / Answer

import java.util.Scanner;
public class Investment

{

    public static double Investment

{

            double investmentAmount, double monthlyInterestRate, int annualInterestRate)

{
        double Investment = 1;
       for ( annualInterestRate = 1; annualInterestRate <= 30; annualInterestRate++)

{
      //Obtain interest rate
      monthlyInterestRate = annualInterestRate /1200;


      //Calculate Payment
        Investment = investmentAmount * Math.pow((1+monthlyInterestRate), annualInterestRate*12);
       }
     return Investment;
       }
  
public static void main(String[] args)

{
        Scanner input = new Scanner(System.in);


        //Prompt the user to enter the invested amount
        System.out.print("The amount invested: ");
        double investmentAmount = input.nextDouble();


        //Promp the user for the anual Interest Rate
        System.out.print("Annual interest rate: ");
        double annualInterestRate = input.nextDouble();
        for (int annualInterestRate = 1; annualInterestRate<=30; annualInterestRate++ )

{
            System.out.print( annualInterestRate);
            System.out.printf("%4d",Investment);
        }
System.out.println();
}

}

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