Ask Question

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

+3
Answers (1)
  1. 19 September, 09:23
    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?
Find an answer to your question 👍 “Write two functions with these headers: function doFV () function computeFutureValue (principal, annualRate, years, periodsPerYear) The ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers