3.a.

3.a.i.

The purpose of this program is to help users decide which cars they should rent from our fictional rental car business.

3.a.ii.

The video demonstrates the inputting answers to the questions which it is being asked. Based on what the user chooses to answer, the program will choose which response to return to the user. As the video shows, if the user chooses to put in different answers, then the response will change.

3.a.iii.

The inputs of the program are the HTML radio buttons which the user selects for each question, as well as the button to submit their answers, prompting the program to run.

3.b.

3.b.i.

3.b.ii.

3.b.iii.

The variable userAnswers is used to represent the answers which the user selected, as it gets all of the elements under the class name “answer” (each of the radio buttons are assigned to the class of “answer”). There are four more variables which are used to represent these answers: a1score, a2score, a3score, and a4score.

3.b.iv.

Each question has 4 possible answers, all of which are assigned a value of “a1”, “a2”, a3”, or “a4”. These values correlate with the desired luxury of car based on what the answer is, with a1 being the lowest luxury, and a4 being the highest. The number of each value selected is calculated and assigned the variables of a1score, a2score, a3score, and a4score. Depending on which of the “scores” is highest, the program will select a response which recommends cars based on the amount of luxury it is assumed the user desires, based on what they answered.

3.b.v.

Without using the data collected in a1score, a2score, a3score, and a4score, the code would be nearly impossible to make, as there would be no other easy way to represent the user’s answers and calculate them.

3.c.

3.c.i.

3.c.ii.

3.c.iii.

The procedure calculateAnswers calculates the “score” for each of the values of “a1”, “a2”, “a3”, and “a4”. This contributes to the overall functionality of the program because these scores are later used to determine which cars the user should consider renting.

3.c.iv.

This procedure first defines the variables of “a1score”, “a2score”, “a3score”, and “a4score”, and sets them all equal to 0. It then uses the variable “userAnswers” to represent each of the possible answer choices the user could select. It then uses a for loop for the length of userAnswers. Within that for loop there is an if statement saying if userAnswer is checked, or the user selected it. Within that if statement, there is for more if statements, saying that if the value of the checked answer is a1, a2, a3, or a4, to add 1 to a1score, a2score, a3score, and a4score respectively. It then returns the values of a1score, a2score, a3score, and a4score.

3.d.

3.d.i.

First call: The first is to assign the calculated answers to a variable called “answers”, and each of the variables of a1score, a2score, a3score, a4score can be redefined

Second call: Function is called again in the calculation for the max score

3.d.iii.

Condition(s) tested by first call: The conditions are to allow the variables a1score, a2score, a3score, and a4score to be used later on

Condition(s) tested by second call: The conditions are to find which one is the max of the calculated answers

3.d.iv.

Results of the first call: a1score, a2score, a3score, and a4score are now assigned outside of the procedure and can be used later on

Results of the second call: Highest score is determined.