Javascript program, computer science homework help

Anonymous
timer Asked: Oct 11th, 2016
account_balance_wallet $20

Question Description

Write a simple HTML/Javascript program which is capable of computing the area of a rectangle as follows:

· 

 On the HTML page, display:

  Two "input" fields where a human can enter a number/value

  One field should be labeled on the screen as "Length"

  One field should be labeled on the screen as "Width"

  button labeled "Calculate Area".  Clicking this button should:

  Calculate and Display the area value of the shape in an "Alert Box"utilizing the user-provided values in the input fields.

  Additionally, if the Length and Width are equal, an "alert box" should display "Hey, that's just a square!".

  In a separate Javascript file

  Create a function called getShapeArera which:

  Performs the appropriate calculation and updates the page as described above.

(This is the function that should be called when when the user clicks the "Calculate Area" button described above.)

----------------------------------------------------------------------------------------------------------------------------------------

Usually, lines of textual data must be properly aligned on a screen or page for easy viewing, Write a JavaScript function called stringPad(str, padChar)that accepts three parameters as follows:

·  An arbitrary string (like a name, for example)

·  A string to be used as a "padding character" to fill in extra space (see the example)

·  The total length of the new string (see example)

The function should return a new string

·  With an LOWER-cased version of str following the "pad characters"

·  Such that the total length of the new string is equal to the new provided

·  If the desired "total length" is less than the length of the input string, then just the input string is returned.

For example:

A call to stringPad("Hello", "*", 10) would return:  *****hello

A call to stringPad("xYZ", "-", 5) would return: --xyz

A call to stringPad("AbCDe", "#", 2) would return: abcde


Tutor Answer

finished
School: University of Maryland

flag Report DMCA
Review

Anonymous
Thank you! Reasonably priced given the quality not just of the tutors but the moderators too. They were helpful and accommodating given my needs.

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors