MIDTERM MIS 3371 SPRING 2020 PARKS

1. (50 points) The textarea named ta1 shown to the left is in a form named f1. It contains contains the 2015 Top 100 billionaires (from here). For each person, the following data is shown:
    Rank followed by a comma
    Name followed by a comma
    Citizenship followed by a comma
    Age followed by a comma
    Net Worth USD billion followed by a comma
    Source(s) of wealth followed by a semicolon (except for the last one)
Write the javascript function named p1() that:
    1. Retrieves the data from the textarea ta1
    2.Creates a 100 row by 6 column table containing the data.
        [ Use NO column headings for the table ].
    3. Calculates the average age
    4. Calculates the average net worth
    5. Counts the number of billionaires from the US
    6. Places the table and items 3→5 above in the DIV block with id="p1_out".
CAUTION: some values of Age are shown as "n/a". Skip these ages in your calculations.

this is the DIV block with id="p1_out"

Show NO HTML. Show only the javascript for p1.
My Core GPA Calculator
 Hrs  Course Grade  Course Grade 
 Communication  6
 Mathematics 3  
 Sciences 6
 Philosophy 3  
 Arts 3  
 History 6
 Politics 6
 Psychology 3  
 Writing 3  
My CORE GPA is SPAN with id="s1" based on SPAN with id="s2" hours
SPAN with id="s3"

2. (50 points) The application shown to the left is used to calculate the student's grade point average (GPA). There are thirteen core courses shown. For each course there are two text boxes where the user can enter information about each course. There are thirteen text boxes in the two 'Course' columns for entering the 8 character course number (HTML elements 0,2,4,6,...). There are thirteen text boxes (HTML elements 1,3,5,7,...) for recording the 'Grade' values to the right of each 'Course'. All the textboxes are in a form named f2. The GPA is calculated by accumulating grade points for each of the thirteen grades:
  1. A grade of "A" is worth 4 grade points
  2. A grade of "B" is worth 3 grade points
  3. A grade of "C" is worth 2 grade points
  4. A grade of "D" is worth 1 grade points
  5. A grade of "F" is worth 0 grade points
The student's gpa is the sum of all the grade points earned divided by the number of courses with grades assigned. Empty 'Grade' textboxes are not used in the gpa calculation. For example, if there are only 11 textboxes that have grades, then the calculated gpa is the sum of the eleven grade point values divided by 11.
When the user enters the data, and clicks on the "Calculate My CORE GPA" button, the function named p2() should:
    (a) Calculate the students GPA by:
        1. Assigning 4 grade points for each "A", 3 grade points for each "B", 2 grade points a for each "C" etc.
        2. Dividing the total grade points by the number of grades, yielding the calculated gpa value.
    (b) In the SPAN block with id="s1", place the calculated gpa using the .toFixed(2) method.
    (c) In the SPAN block with id="s2", place the total number of hours taken (NOT NUMBER OF COURSES TAKEN).
    (d) In the SPAN block with id="s3", place the five grades and the number of times each grade occurred
The textbox values are referenced using: document.f2.elements[ i ].value where i is 0 → 25
Use this array:   var gc = [0,0,0,0,0]; for the counts of each grade
Use this array:   var letters = ["A","B","C","D","F"]; inside your loops for grade values
All classes are 3 hours. Show NO HTML. Show only the javascript for p2.