1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
tamaranim1 [39]
3 years ago
8

A file named loan.html, write an HTML document that looks similar to figure 9-7 in the textbook. Write four functions with these

headers:
function doPayment ( )
function doBalance ( )
function computePayment (principal, annualRate, years, periodsPerYear)
function computeBalance (principal, annualRate, years, periodsPerYear, numberOfPaymentPaidToDate)
The first two functions (doPayment and doBalance) do the following:

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 d payments have been made is

b = a (1 + r)d − p ( (1 + r)d − 1 )
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 d is the number of payments paid to date.
Computers and Technology
1 answer:
jok3333 [9.3K]3 years ago
6 0

Answer:

function computePayment(principal, annualRate, periodsPerYear){

   var pay;

   pay = (principal * annualRate)/(1-(1+annualRate)-periodsPerYear);

   return pay;

}

function computeBalance(principal, annualRate, periodsPerYear, numberOfPaymentsPaidToDate){

   var balance ;

   let num = (principal*(1+annualRate)*periodsPerYear);

   let denum = numberOfPaymentsPaidToDate *((1+annualRate) * periodsPerYear-1)*annualRate;

   balance = num-denum;

   return balance;

}

function doPayment(){

   let loanAmount = document.getElementById("principal").value;

   let rate = document.getElementById("rate").value;

   let duration = document.getElementsById("time").value;

   let result = computePayment(loanAmount, rate, duration);

   document.getElementsById("periodPay").value = result;

}

function doBalance(){

   let loanAmount = document.getElementById("principal").value;

   let rate = document.getElementById("rate").value;

   let duration = document.getElementById("time").value;

   let currentPaid = document.getElementById("paidMonths").value;

   let result = computeBalance(loanAmount, rate, duration, currentPaid);

   document.getElementById("displayBalance").value = result;

}

Explanation:

The javascript source code defines four functions. The 'doPayment' and 'doBalance' functions are initiated with the onclick properties of the HTML file buttons of the loan calculator. The doPayment function gets the user input from the HTML file and assigns them to variable which are used as the parameters of the computePayment function called.

The doBalance function also retrieve user input from the HTML file and calls the computeBalance function to calculate and return the balance of the loan to be paid.

You might be interested in
In this lab, you complete a partially prewritten Python program that uses a list.
PSYCHO15rus [73]

Answer:

See Explanation

Explanation:

Required

Complete the given code

First, it should be noted that the original code (in the question) is complete, however it is poorly formatted.

The errors that may arise when the code is run is as a result of the poor format of the code.

I've corrected all errors and I fixed the indentations in the original code.

<em>See attachment for the complete code.</em>

Download txt
4 0
3 years ago
Give an example of an if/else statment and a case statment that are equivalent. Your example should contain at least three choic
zimovet [89]

Answer:

The if - else and equivalent switch case statements in c++ language are given below.

if ( ch == 1 )

       cout << " sum is " << x + y << endl;

   else if ( ch == 2 )

       cout << " difference is " << x - y << endl;

   else if ( ch == 3 )

   {

       cout << " Quitting " << endl;

       exit;

   }

switch( ch )

   {

       case 1 :    cout << " Sum is " << x + y << endl;

                   break;

       case 2 :    cout << " Difference is " << x - y << endl;

                   break;

       case 3 :    cout << " Quitting " << endl;

                   break;

   }      

Explanation:

The above statements use three variables which are declared and initialized as shown.

int x = 10;

    int y = 25;

    int ch;

The above statements execute for of addition, subtraction or to quit the program.

cout << " 1. Addition " << endl;

    cout << " 2. Subtraction. " << endl;

    cout << " 3. Quit " << endl;

    cout << " Enter your choice " << endl;

The variable ch holds the numerical option entered by the user.

    cin >> ch;

For if - else statements, the if statement is executed based on the value of variable ch entered by the user. After execution, the compiler goes out of the statements automatically.

Following the if – else, if any statement is present, it will be executed.

For switch case, every case ends with break keyword. After the required case is executed based on the value of variable ch entered by the user, the break statement is executed which causes the switch case to terminate the control goes out of the statements.

Following the switch case, if any statement is present, it will be executed.

4 0
3 years ago
Why is Internet fraud becoming increasingly common?
Nikitich [7]
The internet has billions of users, and is gaining more everyday. As people gain more and more technological resources, it becomes easier for them to steal people’s information.
7 0
3 years ago
There are nearly ____ billion people in the world who do not have internet access.
o-na [289]
<span>There are nearly 4.2 billion people in the world who do not have internet access.</span>
6 0
3 years ago
The processor in Q1 above is converted into an 8-stage pipeline, similar to the one discussed on slide 8 of lecture 16. It takes
Nadusha1986 [10]

Answer:

1000/125 billion instructions per second.

Explanation:

All the stages take 125ps and latch time was outlooked.

The clock speed would be the highest stage time in all 5 stages. Here all are same clock speed it would be 125ps only.

throughput = 1/cycle time so ⇒ 1/125 instructions/ps

Since we want it in billion instructions per second so we have to multiply with 10⁻⁹ /10⁻¹² then the result is 1000/125 billion instructions per second.

3 0
3 years ago
Other questions:
  • Let's say that you handle the IT systems administration for your company. There's a server inside of your organization that chec
    14·1 answer
  • An algorithmic function that takes an input message of arbitrary length and returns an output of fixed-length is called a(n) ___
    10·1 answer
  • In her presentation, Emily has inserted two tables in a slide and formatted the text on all slides. Which feature of the present
    12·1 answer
  • WILL GIVE BRAINLIEST!!!!!!!!
    6·1 answer
  • By default, the Windows desktop displays
    6·1 answer
  • What are some effective methods for scrolling? Check all that apply.
    6·1 answer
  • While typing out his assignment henry makes use of leading. What could be the probable reason for him to do so.
    9·2 answers
  • Why do we need IP Addresses in order for the Internet to function properly?
    7·1 answer
  • How do computers benefit individuals' health care?
    10·1 answer
  • g Write a recursive function all capital (L,start ,stop) that takes a string L and two integers. It returns a Boolean (True/Fals
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!