|
1. (50 points) The textarea to the left is named ta1 and is in a form named f1 The data contained in ta1 is the 'Top 500 Remodeling Companies in the USA' (from http://www.qualifiedremodeler.com/top-500/). Each company has 8 elements:
- rank followed by a comma;
- company name followed by a comma;
- description followed by a comma;
- city followed by a comma;
- state name followed by a comma; [these will match one of the names in the s array -- see below]
- Total Gross Sales followed by a comma;
- Remodeling Gross Sales followed by a comma;
- Number of Remodeling Jobs followed by a "*" (except the last one).
Assume there is a 50 element array in the function p1 (DO NOT write this array) that contains the fifty state names like this:
s = ['Alabama','Alaska', ... ,'Wisconsin','Wyoming'];
and two 50 element arrays g and n that are initialized to fifty zeros and are used to store the total "Remodeling Gross Sales" for each state and the total "Number of Remodeling Jobs" for each state, respectively:
g = [0,0,0,0, ... ,0,0,0,0];
n = [0,0,0,0, ... ,0,0,0,0];
When the "Execute p2" is clicked the javascript function p2 is executed. Write the javascript function p1 that:
- Creates a 50 row x 4 column table that contains:
column 1: State name
column 2: Total "Remodeling Gross Sales" for the state (item 7 for the company)
column 3: Total "Number of Remodeling Jobs" for the state (item 8 for the company)
column 4: Average Remodeling Job Cost (col 2/col 3)
- Following the table shows (a) state name that has the (b) minimum average "Remodeling Job Cost". NOTE: if the "Number of Remodeling Jobs" for a state is zero:
(a) DO NOT consider the state in the minimum average determination, and
(b) place "NONE" on the fourth column
Show only the javascript for p1. Do NOT put a heading row in the table.
this is the p1_out DIV
|