Read everything before doing anything.
In the head of your document,
write one JavaScript function
named stars that takes a number
n as its
argument and then produces a paragraph that contains a line of
n asterisks. Thus, calling stars(20) will
produce a paragraph containing twenty asterisks.
Write another function that will use the
built-in prompt() function to ask the user to
enter a number from 1 to 100. This number will be stored in a
global variable. You may give any name you wish to the function
and the global variable. If the user enters a number that is not
in the range 1 to 100, you must give an error message as an alert.
See a sample error alert.
Write another function that will take the global variable and convert it to dozens and units, and display an alert that shows the original number, the dozens, and the units. See a sample of what the result will look like.
Use the following XHTML as the basis for your solution. Copy and paste it into a file of your own. Do not retype the whole page; this is not an XHTML typing contest! (If I see spelling or grammar errors in your solution’s XHTML, I will know that you did not follow this instruction, and I will take off points!)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>CIT041J Program 1</title> <!-- your global variable and functions go here --> </head> <body> <!-- your script to draw twenty asterisks goes here --> <h1>CIT 041J Program 1</h1> <!-- your script to draw forty asterisks goes here --> <!-- the link below prompts user for a number --> <p><a href="#" onclick="">Enter a number from 1 to 100.</a> </p> <!-- the link below converts the number to dozens and units --> <p><a href="#" onclick="">Convert to dozens and units</a> </p> </body> </html>
Name your file in the form lastname_firstname_1.html and email it to the instructor. So, if your name is Fred Bloggs, you would name your file bloggs_fred_1.html.