Difference between revisions of "CSC103 Final Exam"
(New page: ==Problem #1== ===Question 1=== Write a javascript program based on the [http://tango.csc.smith.edu/dftwiki/index.php/CSC103_Lab_3 Javascript Lab] we did in class that computes the '''volu...) |
(→Question 1) |
||
Line 10: | Line 10: | ||
[[Image:CSC103_Rice_Chessboar1.png]] | [[Image:CSC103_Rice_Chessboar1.png]] | ||
− | + | Of course the numbers shown in the image above are not the correct numbers your program has to output! | |
− | |||
− | Some important conversion equations: | + | |
+ | Some important conversion equations you will need: | ||
1 cubic meter (m<sup>3</sup>) contains 1,000,000,000 cubic millimeters (mm<sup>3</sup>). | 1 cubic meter (m<sup>3</sup>) contains 1,000,000,000 cubic millimeters (mm<sup>3</sup>). | ||
Line 24: | Line 24: | ||
var factor = 4168181825.5; | var factor = 4168181825.5; | ||
− | Copy/paste the code of your javascript program in a Word document (or some other word processor of your choice) which you will hand back in on the due date. | + | Copy/paste the code of your '''javascript program''' in a Word document (or some other word processor of your choice) which you will hand back in on the due date. |
===Question 2=== | ===Question 2=== |
Revision as of 08:15, 7 October 2008
Problem #1
Question 1
Write a javascript program based on the Javascript Lab we did in class that computes the volume of all the grains of rice that would have to be put on the 64th square of a chessboard, if we were to start putting 1 grain on the first square, 2 grains on the second square, 4 grains on the next, 8 grains on the next, and so on, doubling every time the number of grains. You may want to read the problem statement in the lab again!
We will assume that the volume of a grain of rice is 2 mm3 (cubic millimeters).
Your program should output the volume of all the grains of rice on the 64th square in cubic miles. Its output should look something like this:
Of course the numbers shown in the image above are not the correct numbers your program has to output!
Some important conversion equations you will need:
1 cubic meter (m3) contains 1,000,000,000 cubic millimeters (mm3). 1 cubic mile contains 4,168,181,825.5 cubic meters.
Note, when you enter a value in a variable in javascript, you do not use comas to isolate groups of 3 digits. For example, if you wanted a variable called factor to contain the last conversion number above, you would write:
var factor = 4168181825.5;
Copy/paste the code of your javascript program in a Word document (or some other word processor of your choice) which you will hand back in on the due date.
Question 2
What is the volume of all the grains of rice that would have to be put on the board, that is the volume of the sum of the grain on the first square, plus the grains on the second square, third, fouth, etc. 64th?
Again, your answer should be in square miles.