2014-09-18 HW8

posted Sep 18, 2014, 11:10 AM by Samuel Konstantinovich   [ updated Sep 18, 2014, 11:43 AM ]
Urgent: There will be a quiz Monday, on how computers work, social consequences of computing, and the jargon. (Everything from before we started scheme)

Home Work #8: 
Bring a printed copy of both functions to class tomorrow (include your heading!)
Since you should be testing the code on the computer, a handwritten copy is not acceptable.
Make a function that checks if 3 integer values are a valid Pythagorean triple, it should return true when it is or false otherwise. (Don't worry about non-integer values)

Version 1: You can assume C is the largest term. If The largest term is not put into C, then the results will be false (because the formula will not work)

Write (isPyTripleEasy A B C) 

(isPyTripleEasy 3 4 5) --> true
(isPyTripleEasy 5 4 3) --> false   even though we know in reality this should be true, this function doesn't check the alternate order of side lengths.
(isPyTripleEasy 3 5 4) --> false
(isPyTripleEasy 3 4 6) --> false

Version 2: the order does not matter. It should give correct results no matter the sequence.
Write (isPyTriple A B C)     ---This is tricky try your best, and remember all the things we learned in class today. You have all the tools to complete the task.

(isPyTriple 3 4 5) --> true
(isPyTriple 5 4 3) --> true
(isPyTriple 3 5 4) --> true
(isPyTriple 3 4 6) --> false

Hint for 2: you only need one expression, but it can be a long and complicated one.

Partial Solution to HW7.
a. (define (volumeSphere r) (/ 3 (* 4 r r r 3.1415926535)))
b. (define (sumofsquares a b) (+ (* a a) (* b b) ))