MIS 3371 MIDTERM SPRING 2018 PARKS ANSWERS

.
1. (50 points) The fastest 100 computers in the world in November 2017 are shown to the left in a textarea named ta1 in a form named f1 (see:www.Top500.org). The data for each computer is organized as follows:
  1. rank followed by a ";". The ranks are arranged from 1 to 100.
  2. website link followed by a ";"
  3. country followed by a ";"
  4. system followed by a ";"
  5. computer followed by a ";"
  6. cores followed by a ";"
  7. performance followed by a "$" (except for the last one)
Write the javascript function named p2 that:
  1. creates a string named os to store the output information
  2. retrieves the data from the textarea named ta1
  3. creates a 100 row by 7 column table using the seven data items for each computer as the column values. As the table is being created, count the number of times the country = "United States". DO NOT create a heading row.
  4. following the table creation, adds to the string os the HTML necessary to display on a line by itself the number of times the "United States" appeared in the country column
  5. places the string os in the DIV block whose id="p1_out">
this is the DIV block with id="p1_out"

Show NO HTML. Show only the javascript for p1.

 

AMMONITE 0

 
this is the DIV with id="p2_out_"

ammonite name

 

2. (50 points) To the left are four parts of a table cell.
  1. a DIV block containing the text string "AMMONITE" followed by a SPAN block with id="image_num_display"
  2. a DIV block with id="p2_out"
  3. a DIV block with id="am_name">
  4. a button labelled "NEXT IMAGE" with onclick="p2( )"
Assume the following two arrays have been defined:

var path_file_names = ["path and image file name", ... there are 19 of these ... ];
var ammonite_names = ["ammonite fossil scientific name", ... there are 19 of these ... ];"

Further assume that there are two global variables:
     (1) image_num that has been set to zero; and
     (2) url that has been set to: "http://www.fossilmuseum.net/"

Write the javascript function p2 that:

  1. creates a string named src_val that contains the concatenation of the string url and the path and file name contained in the array named path_file_names. Use the current value of image_num as the index.
  2. creates a string named img_tag that forms an HTML image tag using the string src_val as the source atrribute and "250" as the width attribute.
  3. places the value of img_tag string into the DIV with id="p2_out"
  4. places the fossil name from the array ammonite_names using image_num as the index into the DIV with id="am_name"
  5. adds 1 to image_num
  6. places the value of image_num in the SPAN block with id="image_num_display"
  7. if image_num exceeds 18, set image_num to zero.
Show NO HTML. Show only the javascript for p2.
Images from: http://www.fossilmuseum.net/