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

Java Programming question on eclipse, I am trying to get my program to return a

ID: 3923311 • Letter: J

Question

Java Programming question on eclipse,

I am trying to get my program to return a value of the future value and it will not return a value instead it returns NaN.

here is a copy of my program!

import java.math.*;

import java.util.*;

public class FutureValue {

  

static double P; //Payment amount

static double r;

static double N;

static double FV;

   /**

   * Name:

   * Last Updated:

   * Project 3: Future Value of Periodic Savings

   * This program calculates the number of deposited payments, the amount deposited,

   *    and the interest rate. The program will then display the amount in the account after

   *    the user enters all prompted information.

   */

   public static void main(String[] args) {

       PrintDirections ();

       FV = Compute_FV ();

           DisplayResults ();

}

   public static void DisplayResults () {

       System.out.println (FV);

   }

  

   public static void PrintDirections() {

  

       System.out.println("This program calculates the future value of the account. Program will ask for the number of deposited payments, the amount deposited, and the interest rate and then display the future amount in the account after the user enters all prompted information.");

       System.out.println("The future value is");

   }

   public static void GetParameters() {

       P= 30.00;

       r= 0.001871154;

       N= Math.pow(1+r, 50);

      

  

      

   }

  

  

   public static double ComputePOW() {

       return Math.pow (r+1,50);

      

   }

  

   public static double Compute_FV() {

       FV = P*((Math.pow (r+1, 50))-1*(r+1)/r);

       return FV;

      

   }

   public static void Report_FV(double FutureValue)

   {

      

       System.out.printf("");

   }

}

Explanation / Answer

HI, you need to call GetParameters() before calling Compute_FV.

import java.math.*;
import java.util.*;
public class FutureValue {

   static double P; //Payment amount
   static double r;
   static double N;
   static double FV;
   /**
   * Name:
   * Last Updated:
   * Project 3: Future Value of Periodic Savings
   * This program calculates the number of deposited payments, the amount deposited,
   * and the interest rate. The program will then display the amount in the account after
   * the user enters all prompted information.
   */
   public static void main(String[] args) {
       PrintDirections ();
       GetParameters();
       FV = Compute_FV ();
       DisplayResults ();
   }
   public static void DisplayResults () {
       System.out.println (FV);
   }

   public static void PrintDirections() {

       System.out.println("This program calculates the future value of the account. Program will ask for the number of deposited payments, the amount deposited, and the interest rate and then display the future amount in the account after the user enters all prompted information.");
       System.out.println("The future value is");
   }
   public static void GetParameters() {
       P= 30.00;
       r= 0.001871154;
       N= ComputePOW();
   }


   public static double ComputePOW() {
       return Math.pow (r+1,50);

   }

   public static double Compute_FV() {
       FV = P*(N-1*(r+1)/r);
       return FV;

   }
   public static void Report_FV(double FutureValue)
   {

       System.out.printf("");
   }
}

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