Java Programming question on eclipse I am trying to get my p

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(\"\");

   }

}

Solution

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(\"\");
   }
}

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.
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.
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.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site