This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: CS 135 Winter 2011 Brad Lushman Assignment: 1 Due: Wednesday, January 12, 2011 10:00am Language level: Beginning Student Files to submit: constants.rkt , functions.rkt , fuel.rkt , grades.rkt Warmup exercises: HtDP 2.4.1, 2.4.2, 2.4.3, and 2.4.4 Practise exercises: HtDP 3.3.2, 3.3.3, and 3.3.4 For this and all subsequent assignments the solutions you submit must be entirely your own work. Do not look up either full or partial solutions on the Internet or in printed sources. Please read the course Web page for more information on assignment policies and how to submit your work. Make sure to follow the style and submission guide available on the course web page when preparing your submissions. Your solutions for assignments in this course will be graded both on correctness and on readability, meaning that, among other things, you should use constants and parameters with meaningful names. Note that for this assignment only, you do not need to include the design recipe in your solutions. A well-written function definition is sufficient. You will not be able to submit this assignment (or any later one) before you have first received full marks in Assignment 0. Each assignment will start with a list of warmup exercises. You dont need to submit these, but we strongly advise you to do them to practice concepts discussed in lectures before doing the assignment. This weeks warmup exercises are HtDP exercises 2.4.1, 2.4.2, 2.4.3, and 2.4.4. Here are the assignment questions you need to submit. 1. Translate the following constant definitions into Scheme. Place your solutions in the file constants.rkt . Note that for this question only, you will not be able to Run this Dr- Racket file. (a) An example from algebra (the harmonic mean ): mean = 3 1 x + 1 y + 1 z (b) An example from geometry (the cosine law ): a = b 2 + c 2- 2 b c cos d (c) An example from physics ( the Lorentz factor ): gamma = 1 q 1- v 2 9 10 16 CS 135 Winter 2011 Assignment 1 1 2. Translate the following function definitions into Scheme. Place your solutions in the file functions.rkt . (a) An example from statistics ( logit ): logit ( p ) = log p 1- p (b) An example from analysis ( Stirlings approximation ): Stirling ( n ) = 2 n n e n (c) An example from physics ( ballistic motion ): height ( v,t ) = v t- 1 2 g t 2 where g is the constant 9 . 8 (acceleration due to gravity) 3. Fuel efficiency of motor vehicles in the United States is typically measured in miles per gallon (mpg), i.e. the number of miles a vehicle can travel on a gallon of gasoline. In Canada, where most quantities are measured in metric units, fuel efficiency of motor vehicles is given in litres per hundred kilometres (L/100km), i.e. the number of litres of gasoline required for the vehicle to travel 100km. In this question, you will write a function to convert fuel efficiency from US to Canadian units. Write the function mpg- > L/100km that consumes a US fuel efficiency (measured in mpg) and produces the equivalent Canadian fuel efficiency...
View Full Document
This note was uploaded on 10/02/2011 for the course CS 135 taught by Professor Vasiga during the Winter '07 term at Waterloo.
- Winter '07