CSCI 242 Exam 2 -- Open Section

You are strongly encouraged to save your answers to a file which you can uploaded to Moodle submission page for Exam 2. However, you can also write your answers on lined paper and turn them in at the end of the period.

Many of these questions are similar to homework problems. You are welcome to consult your homework in writing your answers.

If you add up the points for the closed and open sections of the exam, you will get 80. You are being given a 20-point head start.

In the next three questions suppose will be writing some useful code for a web application that prompts a “user” for a UNCA-style course number, four letters followed by three digits, and does something interesting.

Question 1 (8 points)

In Homework 4 you wrote a simple application that asked its “user” for a name. For this question, write the HTML code that displays a simple form where the “user” can enter a course number and then press a submit button for processing.

Question 2 (8 points)

Write a little JavaScript that works with your Question 1 answer to transfer the course number entered by your “user” into a JavaScript variable called courseNumber.

Question 3 (12 points)

Now you need to do something similar to Homework 6. First, make an XMLHttpRequest to the server with URL passing a JSON structure containing only courseNumber. To avoid some typing, you can assume the following JavaScript statement has been placed in your program.

var url = '' ;

The response to your request will be a two-field JSON structure containing the cost and instructor of the course. Here the field names will be cost and instructor. To complete your solution for this question, all you need to do is store this information into JavaScript variables named courseCost and courseInstructor.

Question 4 (16 points)

Assuming that conTxt is a 2D context object, use the JavaScript Canvas API to make a drawing with a vague resemblence to the following.
pointless drawing