2014-09-17 HW7

posted Sep 17, 2014, 11:05 AM by Samuel Konstantinovich   [ updated Sep 17, 2014, 11:05 AM ]
Write the scheme functions below. Submit your solutions including your header on the HW server.

note:
1. Your file should run. Any non-scheme text should be commented out!
2. Your header should be in comment format:

;LAST NAME, FIRST NAME
;STUY ID
;MKS21 Period<x>
;DD-MM-YYYY

HW7:
1. Write a scheme function  (volumeSphere R) that evaluates to the volume of a sphere with radius R.
2. Write a scheme function  (sumofsquares A B) that evaluates to the sum of the square of A and the square of B.

;Answer question 3 as a comment in your code, before writing the function in question 4.
3. If you wanted to answer question 4, how would you start this problem?
What do you need to know before you write any code?

4. Write a scheme function to calculate the force between two objects using Newton's Law of Universal Gravitation.

(read the wiki for an explanation of the formula: http://en.wikipedia.org/wiki/Newton's_law_of_universal_gravitation )
You don't need to understand the science behind the formula! You need to understand how to model something that you are not familiar with yet.


HW6 solutions:
1a.   (+ (/ (- 5(* 4 2)) (- 10 5) ) 3) 
 b.  (/ (+ 2 (* 3(- 4 2))) (- 1 (/ 3 5)) ) 
2. Evaluate the expressions (show the steps you took line by line) You may verify your result using DrScheme. Parts f and g require you to refer back to Part1 of the assignment. 
 a. ( * (+ 4 7 9) (/ 15 5) (- 3 -1) )
    (* 20 3 4)
     240
 b. (/ (- 20 -4)   (* -3 2 -1))
    (/ 24 6)
    4
Comments