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

The present value on an investment of A dollars for Y years at annual rate of R

ID: 3683529 • Letter: T

Question

The present value on an investment of A dollars for Y years at annual rate of R percent compunded C times yearly is

Formula (1) Present Value = A(1 + R/C)YC

Of course, if interest is compounded yearly, then C = 1 and formula (1) simplifies to :

Formual (2) Present Value = A(1 + R)Y  

Overload a method presentValue(...) so that presentValue(...) implements both formulas (1) and (2), using Math.pow(...) . Also Write a main(...) method that tests both versions of presentValue(...)


Program to Write

• The method headers for the presentValue(…) methods are:

double presentValue(double a, int y, double r, int c)
and double presentValue(double a, int y, double r) à c == 1

• The main(…) method should try different values for A, Y, R, and (optionally) C, and call both versions of the presentValue(…) method using those.

Write the program in Java Language.

Explanation / Answer

class Investment

{  

          double presentValue(double a, int y, double r, int c)

{

double result = 0.0;

if (c != 0)

{

result = Math.Pow((a(1+r/c)), yc);

}

return result;

}

          double presentValue(double a, int y, double r)

{

double result = Math.Pow((a(1+r)), y);

return result;

}

public static void main(String args[])

{  

                    Investment obj1 = new Investment();

                    double a=1, y=2, r=3, c=4;

                    Obj1.presentValue (a,y,r,c);  

                    Obj1.presentValue (a,y,r);

Investment obj2 = new Investment();

                    Double a=6, y=7, r=8, c=9;

                    Obj2.presentValue (a,y,r,c);  

                    Obj2.presentValue (a,y,r);  

          }  

}

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