Difference between revisions of "CSC103 Take-Home Final Exam Fall 2012"
(Created page with "--~~~~ ---- <bluebox> This exam is given under the rule of the [http://www.smith.edu/sao/handbook/socialconduct/honorcodestatement.php Smith College honor code]. Your work has t...") |
|||
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
--[[User:Thiebaut|D. Thiebaut]] 11:34, 16 October 2012 (EDT) | --[[User:Thiebaut|D. Thiebaut]] 11:34, 16 October 2012 (EDT) | ||
---- | ---- | ||
+ | <onlydft> | ||
<bluebox> | <bluebox> | ||
This exam is given under the rule of the [http://www.smith.edu/sao/handbook/socialconduct/honorcodestatement.php Smith College honor code]. Your work has to be done individually. You cannot discuss ANY of this material with anybody, with the exception of your instructor. TAs are not allowed to give help about this final exam. | This exam is given under the rule of the [http://www.smith.edu/sao/handbook/socialconduct/honorcodestatement.php Smith College honor code]. Your work has to be done individually. You cannot discuss ANY of this material with anybody, with the exception of your instructor. TAs are not allowed to give help about this final exam. | ||
<br /> | <br /> | ||
Once the last lecture of the 1/2 semester is over, questions can only be addressed via email. Whenever you send your instructor a question, the question and the answer will be broadcast back to the whole class within a short time period (between 7:00 a.m. - 9:00 p.m.). | Once the last lecture of the 1/2 semester is over, questions can only be addressed via email. Whenever you send your instructor a question, the question and the answer will be broadcast back to the whole class within a short time period (between 7:00 a.m. - 9:00 p.m.). | ||
+ | <br /> | ||
+ | Submit your final exam on paper to your instructor (office in FH356) on 10/25/12, at 9:00 a.m. | ||
</bluebox> | </bluebox> | ||
− | |||
=Problem #1: Logic Gates and Boolean Algebra= | =Problem #1: Logic Gates and Boolean Algebra= | ||
− | * What is the | + | * What is the''' boolean equation''' for the output '''Y''' of the circuit shown below? |
<center> | <center> | ||
[[Image:CSC103LogicCircuitFinal.png|500px]] | [[Image:CSC103LogicCircuitFinal.png|500px]] | ||
</center> | </center> | ||
− | <onlydft> | + | |
+ | =Problem #2: Assembly Language= | ||
+ | * Write an assembly language program that contains a loop and at least one variable called '''sum'''. Before the loop starts the variable '''sum''' contains 0. Once the loop ends the variable '''sum''' contains the sum of all the multiples of 3 between 0 and 30. In other words, your program computes 0 + 3 + 6 + 9 + 12 + 15 + 18 + 21 + 24 + 27 + 30 and stores the result in the variable '''sum'''. | ||
+ | |||
+ | ==Submitting the Program == | ||
+ | |||
+ | * Please submit the code of your assembly program the same way you did for previous homework assignments. | ||
+ | * Go to this URL: http://maven.smith.edu/~thiebaut/103/submitfinal.htm | ||
+ | * Enter your 2-letter Id | ||
+ | * Enter the problem number (2) | ||
+ | * Add your name in the top of the text area, prefixed with two semicolons (to make it a comment) | ||
+ | * Paste your code in the text area, and | ||
+ | * Submit it! | ||
+ | <br /><br /><br /> | ||
+ | <tanbox>You should still submit a copy of your program on paper with your final exam.</tanbox> | ||
+ | <br /><br /><br /><br /> | ||
+ | |||
+ | =Problem #3: Processing Language= | ||
+ | [[Image:CSC103ProcessingFinal2012.png|right|150px]] | ||
+ | ==Initial Program== | ||
+ | * Copy/Paste this program into the Processing editor. | ||
+ | <br /> | ||
+ | <code><pre> | ||
+ | // declare a variable called diameter that will contain | ||
+ | // real numbers. | ||
+ | float diameter; | ||
+ | |||
+ | void setup() { | ||
+ | size( 500, 500 ); | ||
+ | smooth(); | ||
+ | } | ||
+ | |||
+ | void draw() { | ||
+ | // put a random number less than 200 into variable diameter | ||
+ | diameter = random( 200 ); | ||
+ | |||
+ | // pick a color with a random amount of red, 100 units of green, and 200 units of blue | ||
+ | fill( random(255),100, 200 ); | ||
+ | |||
+ | // draw 10 circles at random position in the window, with the same diameter. | ||
+ | for ( int i=1; i<=10; i++ ) { | ||
+ | ellipse( random( 500 ), random( 500 ), diameter, diameter ); | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </pre></code> | ||
+ | <br /> | ||
+ | * Run it and observe how it works. | ||
+ | ==Some Explanations== | ||
+ | |||
+ | * There are 2 new elements in the program: | ||
+ | ** <tt>float diameter</tt>, and | ||
+ | ** <tt>random( )</tt>. | ||
+ | * <tt>float diameter</tt> simply says that '''diameter''' is used in the program as a ''variable'' that will contain a real number (real numbers are numbers with a decimal point). | ||
+ | * <tt>random()</tt> is a function that returns a random number. If you call <tt>random(10)</tt>, it will return a random number between 0 and 10, not inclusive. So, when we write: | ||
+ | |||
+ | diameter = random( 200 ); | ||
+ | |||
+ | :we make the sketch store a random number into the variable diameter, and we force this random number to be larger than or equal to 0, and less than 200. | ||
+ | :When we call '''ellipse()''' and write <tt>random(500)</tt> for both the ''x'' and ''y'' coordinates, we make the sketch put a circle in the window at a random position, but we force the center of the circle to remain inside the window. | ||
+ | * Make sure you read the documentation on '''random()''' in the [http://processing.org/reference/ reference section] of [http://processing.org/ processing.org] to fully understand what it does. | ||
+ | |||
+ | ==Your Assignment== | ||
+ | |||
+ | # make your sketch display circles on the window '''only''' when the mouse button is ''pressed''. If the mouse isn't pressed, nothing happens in the window | ||
+ | # make the circles shrink in size if the mouse moves toward the left side of the window. The circles will grow in size if the mouse moves toward the right side of the window. The circles are still random in size, but their maximum size depends on the mouse position. | ||
+ | # make the circles more random in color and not with this strong ''blue'' tint. Moreover, instead of having 10 circles the same color every time ''draw()'' is called, make each of the 10 a different (random) color. | ||
+ | |||
+ | ==Example== | ||
+ | * Here is an example below showing the final sketch running. It is not possible to hear the mouse click but you will see that the generation of circles is interrupted regularly when the user releases the mouse button. | ||
+ | <br /> | ||
+ | <center><videoflash>1g_S8ekD0nk</videoflash></center> | ||
+ | <br /> | ||
+ | |||
+ | ==Submitting the Program == | ||
+ | |||
+ | * Please submit the code of your sketch the same way you did for previous homework assignments. | ||
+ | * Go to this URL: http://maven.smith.edu/~thiebaut/103/submitfinal.htm | ||
+ | * Enter your 2-letter Id | ||
+ | * Enter the Problem number (3) | ||
+ | * Add your name in the top of the text area, prefixed with two slashes (to make it a comment) | ||
+ | * Paste your code in the text area, and | ||
+ | * Submit it! | ||
+ | <br /><br /><br /> | ||
+ | <tanbox>You should still submit a copy of your sketch on paper with your final exam.</tanbox> | ||
+ | <br /><br /><br /><br /> | ||
+ | |||
+ | </onlydft> | ||
+ | |||
<br /> | <br /> | ||
<br /> | <br /> |