{ "key_pair_value_system": true, "answer_rating_count": "", "question_feedback_html": { "html_star": "", "html_star_feedback": "" }, "answer_average_rating_value": "", "answer_date_js": "2024-09-06T02:24:04-04:00", "answer_date": "2024-09-06 02:24:04", "is_docs_available": null, "is_excel_available": null, "is_pdf_available": null, "count_file_available": 0, "main_page": "student_question_view", "question_id": "9266279", "url": "\/study-help\/questions\/please-help-this-code-is-not-computing-correctly-there-must-9266279", "question_creation_date_js": "2024-09-06T02:24:04-04:00", "question_creation_date": "Sep 06, 2024 02:24 AM", "meta_title": "[Solved] Please help this code is not computing co | SolutionInn", "meta_description": "Answer of - Please help this code is not computing correctly. There must be something wrong with the formula. I can't figure it ou | SolutionInn", "meta_keywords": "help,code,computing,correctly,wrong,formula,figure,criteria,assignment,write,four,functions", "question_title_h1": "Please help this code is not computing correctly. There must be something wrong with the formula. I can't figure it out. Here is the criteria", "question_title": "Please help this code is not computing correctly. There must be something", "question_title_for_js_snippet": "Please help this code is not computing correctly There must be something wrong with the formula I can't figure it out Here is the criteria for the assignment Write four functions with these headers function doPayment() function doBalance() function computePayment(principal, annualRate, years, periodsPerYear) function computeBalance(principal, annualRate, years, periodsPerYear, numberOfPaymentsPaidToDate) The first two functions (doPayment and doBalance) take no parameters are called from an onclick attribute get input from the user call the computePayment or the computeBalance function display a result to the user The computePayment function computes and returns the monthly payment for a loan with a fixed annual interest rate The formula for computing a loan payment is P ar 1(1 r) n where p is the payment per period, a is the loan amount, r is the interest rate per period , and n is the total number of periods throughout the life of the loan The computeBalance function computes and returns the balance for a loan with a fixed annual interest rate The formula for computing the balance of a loan after n payments have been made is b a(1 r) n p((1 r) n1) r where b is the balance or payoff amount, a is the loan amount, r is the interest rate per period , p is the payment per period, and n is the number of payments paid to date Loan Calculator Loan Calculator Amount borrowed (Principal) Annual Interest Rate (for example 0 065) Number of years Payments per years Number of payment paid to date function doPayment() let principal document getElementById('principal') value let annualRate document getElementById('annualRate') value let years document getElementById('years') value let payperyear document getElementById('payperyear') value document getElementById('Payment') value '$' computePayment(principal,annualRate,years,payperyear) fs function doBalance() let principal document getElementById('principal') value let annualRate document getElementById('annualRate') value let years document getElementById('years') value let payperyear document getElementById('payperyear') value let paid document getElementById('paid') value document getElementById('Payoff') value '$' computeBalance(principal,annualRate,years,payperyear,paid) function computeBalance(principal, annualRate, years, periodsPerYear, numberOfPaymentsPaidToDate) return principal Math pow((1 annualRate),numberOfPaymentsPaidToDate) periodsPerYear Math pow(1 annualRate,numberOfPaymentsPaidToDate 1) annualRate ", "question_description": "

Please help this code is not computing correctly. There must be something wrong with the formula. I can't figure it out.<\/p>

Here is the criteria for the assignment:<\/p>

Write four functions with these headers:<\/p>

function doPayment() function doBalance() function computePayment(principal, annualRate, years, periodsPerYear) function computeBalance(principal, annualRate, years, periodsPerYear, numberOfPaymentsPaidToDate) <\/pre> 

The first two functions (doPayment and doBalance)<\/p>

take no parameters<\/p>

are called from an onclick attribute<\/p>

get input from the user<\/p>

call the computePayment or the computeBalance function<\/p>

display a result to the user<\/p>

The computePayment function computes and returns the monthly payment for a loan with a fixed annual interest rate. The formula for computing a loan payment is<\/p>

P = ar\/1(1+r)^n<\/p>

where p is the payment per period, a is the loan amount, r is the interest rate per period<\/em>, and n is the total number of periods<\/em> throughout the life of the loan.<\/p>

The computeBalance function computes and returns the balance for a loan with a fixed annual interest rate. The formula for computing the balance of a loan after n payments have been made is<\/p>

b =a(1+r)^n p((1+r)^n1)\/r<\/p>

where b is the balance or payoff amount, a is the loan amount, r is the interest rate per period<\/em>, p is the payment per period, and n is the number of payments paid to date<\/em>.<\/p>

Loan Calculator<\/title> <\/head> <body onlo> <h1 align=\"center\">Loan Calculator<\/h1> <div> <form> <table align=\"center\"> <tr> <td>Amount borrowed (Principal) : <\/td> <td> <input name=\"loan_amount\" type=\"number\" id=\"principal\" value=\"\" required> <\/td> <\/tr> <tr> <td>Annual Interest Rate (for example 0.065)<\/td> <td> <input name=\"annual_rate\" type=\"number\" id=\"annualRate\" value=\"\" required> <\/td> <\/tr> <tr> <td>Number of years<\/td> <td> <input name=\"years\" id=\"years\" type=\"number\" value=\"\" required> <\/td> <\/tr> <tr> <td>Payments per years<\/td> <td> <input name=\"years\" id=\"payperyear\" type=\"number\" value=\"\" required> <\/td> <\/tr> <tr> <td> <input type=\"button\" onclick=\"doPayment()\" align=\"center\" value=\"Compute Payment\"><\/input> <\/td> <td> <input id=\"Payment\" type=\"text\" value=\"\" \/> <\/td> <\/tr> <tr> <td>Number of payment paid to date <\/td> <td> <input name=\"years\" id=\"paid\" type=\"number\" value=\"\" required> <\/td> <\/tr> <tr> <td> <input type=\"button\" onclick=\"doBalance()\" align=\"center\" value=\"Compute Payoff Payment\"><\/input> <\/td> <td> <input id=\"Payoff\" type=\"text\" value=\"\" \/> <\/td> <\/tr> <tr> <td> <input type=\"button\" onclick=\"this.form.reset();\" align=\"center\" value=\"Reset\"><\/input> <td> <\/tr> <\/table> <\/form> <script> function doPayment() { let principal = document.getElementById('principal').value; let annualRate = document.getElementById('annualRate').value; let years = document.getElementById('years').value; let payperyear = document.getElementById('payperyear').value;<\/p> <p> document.getElementById('Payment').value = '$' + computePayment(principal,annualRate,years,payperyear); }<\/p> <p>fs }<\/p> <p>function doBalance() { let principal = document.getElementById('principal').value; let annualRate = document.getElementById('annualRate').value; let years = document.getElementById('years').value; let payperyear = document.getElementById('payperyear').value; let paid = document.getElementById('paid').value;<\/p> <p> document.getElementById('Payoff').value = '$' + computeBalance(principal,annualRate,years,payperyear,paid); }<\/p> <p>function computeBalance(principal, annualRate, years, periodsPerYear, numberOfPaymentsPaidToDate) { return principal*Math.pow((1+annualRate),numberOfPaymentsPaidToDate) - periodsPerYear*Math.pow(1+annualRate,numberOfPaymentsPaidToDate-1)\/annualRate; } <\/script> <\/body> <\/html><\/p>", "transcribed_text": "", "related_book": { "title": null, "isbn": null, "edition": null, "authors": null, "cover_image": null, "uri": null, "see_more_uri": "" }, "free_related_book": { "isbn": "", "uri": "", "name": "", "edition": "" }, "question_posted": "2024-09-06 02:24:04", "see_more_questions_link": null, "step_by_step_answer": "The Answer is in the image, click to view ...", "students_also_viewed": [ { "url": "\/study-help\/modern-mathematical-statistics-with-applications\/142-for-distribution-functions-f-the-second-proof-of-theorem-1987155", "description": "=+14.2. For distribution functions F, the second proof of Theorem 14.1 shows how to construct a measure u on (R', ') such that p (a, b] = F (b) - F(a).", "stars": 0 }, { "url": "\/research-auditing-professional-standards-and-list-the-requirements-related-to", "description": "Research auditing professional standards and list the requirements related to developing an expectation and conducting analytical procedures when those procedures are intended to provide substantive...", "stars": 3 }, { "url": "\/study-help\/questions\/austin-enterprises-makes-and-sells-three-types-of-dress-shirts-9997299", "description": "Austin Enterprises makes and sells three types of dress shirts. Management is trying to determine the most profitable mix. Sales prices, demand, and use of manufacturing inputs follow: $ Basic 28...", "stars": 3 }, { "url": "\/study-help\/questions\/outdoor-adventure-companys-alison-and-zorro-warren-are-continuing-their-1414373", "description": "Outdoor Adventure Company's Alison and Zorro Warren are continuing their analysis of the company's position and believe the company will need to borrow $12,000 in order to expand operations. They...", "stars": 3 }, { "url": "\/study-help\/questions\/this-week-i-would-like-you-to-work-on-the-5174008", "description": "This week I would like you to work on the \"Effective Stress Management\" portion of developing yourself as a leader. Think of stress management from two opposing perspectives: stress situations...", "stars": 3 }, { "url": "\/study-help\/questions\/given-in-a-b-are-stress-states-of-an-1026809", "description": "Given in (a) & (b) are stress states of an element. Are these elements in equilibrium? If not, what are the body forces needed to make the current stress state an equilibrium stress state? (a) -x+y...", "stars": 3 }, { "url": "\/study-help\/questions\/would-the-application-of-a-justintime-production-system-affect-how-1004248", "description": "Would the application of a Just-In-Time production system affect how aggregate planning is conducted? Why? How?", "stars": 3 }, { "url": "\/study-help\/questions\/if-employees-dont-buy-into-the-plan-then-management-will-3203860", "description": "If employees don't buy into the plan then management will be acting on their own. How can management encourage employees to buy into the need to be checked on their way out? Multiple Choice Utilize...", "stars": 3 }, { "url": "\/study-help\/questions\/a-random-forcing-with-a-bandwidth-of-030hz-is-applied-1027330", "description": "A random forcing, with a bandwidth of 0-30Hz, is applied to a structure. The response is measured and converted to the frequency domain, and the mobility Nyquist plot is shown below. How many modes...", "stars": 3 } ], "next_back_navigation": { "previous": "\/study-help\/questions\/required-information-the-following-information-applies-to-the-questions-displayed-9266278", "next": "\/study-help\/questions\/garnet-service-anticipates-the-following-sales-revenue-over-a-fivemonth-9266280" }, "breadcrumbs": [ { "name": "Study help", "link": "https:\/\/www.solutioninn.com\/study-help\/questions-and-answers" }, { "name": "Computer Science", "link": "https:\/\/www.solutioninn.com\/study-help\/questions-and-answers\/computer-science" }, { "name": "Databases", "link": "https:\/\/www.solutioninn.com\/study-help\/questions\/computer-science-databases" }, { "name": "Please help this code is not computing correctly. There must be something", "link": "https:\/\/www.solutioninn.com\/study-help\/questions\/please-help-this-code-is-not-computing-correctly-there-must-9266279" } ], "skill_details": { "skill_id": "656", "skill_name": "Databases", "parent_id": "8" } }