Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS122 – Quiz 2 Winter, 2013 Quiz Hints. Quiz 2 Hints Question 1 – working with the “if” statement  First, we did not fully explain the structure of the.

Similar presentations


Presentation on theme: "CS122 – Quiz 2 Winter, 2013 Quiz Hints. Quiz 2 Hints Question 1 – working with the “if” statement  First, we did not fully explain the structure of the."— Presentation transcript:

1 CS122 – Quiz 2 Winter, 2013 Quiz Hints

2 Quiz 2 Hints Question 1 – working with the “if” statement  First, we did not fully explain the structure of the Maple “if” statement, especially the associated “if-elif-else” versions if (condition1) then – Execute if condition 1 is true; – elif (condition2) then » Execute if condition 2 is true; » Only reach here if condition 1 is false – else » Execute if both conditions 1 and 2 are false end if;

3 Quiz 2 Hints Question 1 – working with the “if” statement  Also, the boolean operator “and” results in “true” only if both conditions are true If (condition1 and condition2) then – Execute this code only if both conditions are true end if;  To answer the 1st 2 parts, just copy and paste the code into a code edit region and execute. The result for “b” will appear below in the execution trace.  To answer the last 2 questions, inspect the code and determine a possible value for “a” (there are numerous potential answers

4 Quiz 2 Hints Question 2 – Gapfinder  This “fill in the blanks” problem is very similar to the Lab 1, problem 4 exercise (the n gap problem). In uses the n-1 gap logic to 1st get you to the last overhang before the gap of interest.  “od” at the end of loops is the same as “end do”  Be careful about in which direction the car is touching the barriers. Question 3 – drive in a square (using nested “for” loops)  Review the Lab 2 problem 1 – figure 8 example and then fill in the blanks.

5 Quiz 2 Hints Questions 4 and 5 – Using the Car Simulator – 1st, some general comments pertaining to both questions It is important to remember from labs 1 and 2 that both the.mw work sheets and the 2 Car Simulator library files must reside in the same folder. That is why we unzipped the file on the course web site and created the folder that contained all necessary files In Maple, we always opened our work sheets for all problems from that folder

6 Quiz 2 Hints Questions 4 and 5 – Using the Car Simulator – 2nd, the 11 step process described in questions 4 and 5 results in your new file (for the question 4 or 5 solution) residing in the folder along with the 2 library files. – It is critical that you understand and can replicate this process because 2 of the 4 questions on the C portion of your proficiency exam will come from this type of example from either quiz 1 or 2. – Please visit the CLC (room 147 UC) with any questions regarding this procedure

7 Quiz 2 Hints Questions 4 and 5 – other tips and hints – For either question, it is possible that the car is NOT originally facing the proper direction. If this is the case, you must start your solution with an appropriate turn. – Note that each question contains 2 sets of code for creating the grid. Each will set up a grid with different spacing between barriers, turns and targets, so you cannot count and code the number of blocks to move for a specific layout. “while” loops are necessary to determine when you are at the target, gap, etc. If both sets of code work, your solution has been correctly coded.

8 Quiz 2 Hints Questions 4 and 5 – other tips and hints – Finally, the easiest way to copy and paste the properly formatted proc code into the quiz solution box is to highlight and copy the blue code under the code edit region (in the execution trace) that is produced when the proc is executed. This will ensure that the appropriate syntax is captured. – The solutions themselves consist merely of the correct ordering of moves, turns and isTouching functions.


Download ppt "CS122 – Quiz 2 Winter, 2013 Quiz Hints. Quiz 2 Hints Question 1 – working with the “if” statement  First, we did not fully explain the structure of the."

Similar presentations


Ads by Google