Ask Question
5 March, 05:24

Write two functions with these headers: function doFV () function computeFutureValue (principal, annualRate, years, periodsPerYear) The first function (doFV) takes no parameters is called from the o nclick attribute gets input from the user calls the computeFutureValue function displays the result to the user

+2
Answers (1)
  1. 5 March, 07:18
    0
    function doFV () { let p = Number (prompt ("Enter principal amount: ")); let a = Number (prompt ("Enter annual rate: ")); let y = Number (prompt ("Enter number of years: ")); let n = Number (prompt ("Enter number of periods per year: ")) computeFutureValue (p, a, y, n); } function computeFutureValue (principal, annualRate, years, periodsPerYear) { let amount = principal * Math. exp ((1 + annualRate / periodsPerYear), n*y); console. log (amount); }

    Explanation:

    The solution code is written in jа vascript.

    Firstly create function doFv that takes no parameter (Line 1). Use prompt method to get user input for principal amount, annual rate, number of years and number of periods per year (Line 2 - 5). This is also important to use Number function to convert the input from string to numerical. After receiving user input, call the function computeFutureValue by passing the four user inputs as arguments (Line 7).

    In the function computeFutureValue, apply compound interest formula to calculate the amount to be paid (Line 12). And use console. log to display the amount to terminal (Line 13).
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write two functions with these headers: function doFV () function computeFutureValue (principal, annualRate, years, periodsPerYear) The ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers