CS 2360 Assignment 1: Due Midnight Jan 16

You should code up and turn in (mail to your TA) the following.

  1. Since I'm a baseball fan, I thought it might be a good idea to have you compute some baseball statistics. Here are some definitions for those of you that are not baseball fans:

    Number of hits
    Sum of singles, doubles, triples, and home runs
    Batting Average
    Number of hits divided by number of at-bats (i.e. how often do you get a hit?)
    On Base Percentage
    Number of hits plus number of walks divided by at-bats
    Slugging Percentage
    Sum of the number of hits of each kind divided by at-bats and multiplied by the number of bases the hit counts. This means that you need to compute the batting average for singles alone and multiply by 1, doubles alone and multiply by two, etc. When you have done these four calculations, then sum result.

    You need to write three functions named NUMBER-OF-HITS, BATTING-AVERAGE, and ON-BASE-PERCENTAGE to compute the first three of these values respectively. The function NUMBER-OF-HITS should take the number of singles, doubles, triples, and home runs as arguments. The BATTING-AVERAGE function should take all those, plus another parameter for number of at-bats. The ON-BASE-PERCENTAGE function should take all those parameters, plus an additional parameter for the number of walks. These functions MUST take these in the order specified here, e.g. OBP must take its parameters in the order singles, doubles, triples, home-runs, at-bats, walks.

    If you are wanting some more practice, try to compute the slugging percentage. It will require the same arguments as batting average. If you do this, try to write a predicate called "BABE-RUTH-P" which will return T or NIL based on if a hitter's SP is greater than .750.

  2. This one is from geometry. We want you to compute one of the angles (in radians) of a right triangle given only the opposite and adjacent sides. Naturally you'll need to compute the hypotenuse to determine the angle, so the first function you should write should be the function HYPOTENUSE which takes the opposite and adjacent side lengths as parameters. To compute this, you will need the function SQRT which computes square roots. One you have the HYPOTENUSE function written, write a function MY-ANGLE which computes the angle by using the ASIN built-in function and your HYPOTENUSE function.

  3. This one is easy. Just work through and type-in Kurt's quadratic formula example and prove to yourself that it works. Note that to do this you will have to write a function to compute the discriminant. Do NOT use the "efficient" version at the end, although this may guide you in coding your discriminant function.


Back To The CS2360 Home Page
Ian Smith (iansmith@cc.gatech.edu)

Last Modified 9 Jan 95 by Ian Smith (iansmith@cc.gatech.edu)