|
1. (50 points) The textarea to the left contains
XML for the top 100 dividend paying stocks (from here).
The DTD is: <?xml version="1.0"?> <!DOCTYPE topdividendstocks[ <!ELEMENT topdividendstocks(stock+)> <!ELEMENT stock (rank,stockname,tickersymbol,sector,yield)> <!ELEMENT rank (#PCDATA)> [values are 1 → 100] <!ELEMENT stockname (#PCDATA)> <!ELEMENT tickersymbol(#PCDATA)> <!ELEMENT sector (#PCDATA)> <!ELEMENT yield (#PCDATA)>] [yield is a number with a decimal point] Assume the javascript function p1() contains: 1. the 11 possible industry sector values stored in an array named sec like this: var sec =["Healthcare","Real Estate","Energy","Utilities","Consumer Staples","Financial", "Consumer Discretionary","Telecommunications","Industrials","Technology","Basic Materials"] [don't write the sec array] 2. create three eleven element arrays: maxyield to hold the largest yield for each sector, intialize all to 0.0 maxname to hold the stockname of the stock with the highest yield, initialize with empty strings numstock to hold the number of stock in each sector, intialize with zeroes 3. assume the XML has been loaded into javascript, and that root.childNodes.length is the number of stocks root.childNodes[i].childNodes[0].childNodes[0].nodeValue is rank root.childNodes[i].childNodes[1].childNodes[0].nodeValue is stockname root.childNodes[i].childNodes[2].childNodes[0].nodeValue is tickersymbol root.childNodes[i].childNodes[3].childNodes[0].nodeValue is sector root.childNodes[i].childNodes[4].childNodes[0].nodeValue is yield 4. then create a 12 row by four column table that shows: a) the first row uses a predefined string named heading (Don't write heading) b) in the remaining 11 rows: in column 1, the industry sector; in column 2, the number of stocks in the sector; in column 3, the largest dividend yield for the sector; in column 4, the stockname with the sector's highest yield 5. place the table in the DIV block with id="p1out" this is the DIV with
id="p1out" |
2. (50 points) The textarea to the
left contains the 2018 largest 50 global companies by revenue (from here).
The data is contained in a textarea named ta2 in a form named
f2. The data for each company is:
Write the javascript function named p2 that:
this is the DIV with
id="p2out" |