For this assignment, you are to define the following Scheme functions. For simplicity, place all of your function definitions in a single file named hw4.scm. Be sure to comment each function as to its behavior.
For example, (in->cm 10) should evaluate to
25.4, while (kg->lb 10) should evaluate to 22.0462262.
BMI = (weight in kilograms) / (height in meters)2
Define a function named BMI-Metric that takes two inputs, a person's height (in centimeters) and weight (in kilograms), and returns his/her BMI. For example, (BMI-Metric 170.0 70.0) should evaluate to approximately 24.22.
Define a function named BMI-American that takes two inputs, a person's
height (in inches) and weight (in pounds), and returns his/her BMI.
For example, (BMI-American 65.0 170.0) should evaluate to
approximately 28.29. Note: you should be able to make use of the BMI-Metric function
here.
BMI < 18.5 | underweight |
18.5 ≤ BMI < 25.0 | normal |
25.0 ≤ BMI < 30.0 | overweight |
30.0 ≤ BMI | obese |
Modify your BMI-Metric and BMI-American functions so that instead of
returning a single number, they each return a list containing the BMI and the weight status.
For example, (BMI-Metric 170.0 70.0) should evaluate to
approximately (24.22 normal)
, while (BMI-American 65.0 170.0) should evaluate to
approximately (28.29 overweight)
.
For example, (leap-year 2008) and (leap-year 2000) should
evaluate to #t, but (leap-year 2009) and (leap-year 2100)
should evaluate to #f.
For example, (days-in-year 2008) should evaluate to 366 since it is a
leap year, but (days-in-year 2100) should evaluate to 365 since it is not.
For example, (total-days 2008 2010) should evaluate to 1096 since the years
in the range consist of 366, 365, and 365 days, respectively.
You may assume the old roman style of writing letters, where 4 is
represented IIII and 90 is represented LXXXX. A harder problem, which
you may attempt if you like, is to use the modern roman style where
4 is IV and 90 is XC.