a01 - CS 135 Winter 2012 Brad Lushman Assignment 1 Due...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 135 Winter 2012 Brad Lushman Assignment: 1 Due: Wednesday, January 11, 2012 9:15am 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 don’t need to submit these, but we strongly advise you to do them to practice concepts discussed in lectures before doing the assignment. This week’s 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 2012 Assignment 1 1
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
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 ( Stirling’s 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 (measured in L/100km).
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern