Main Content

How healthy are the stars of stage and screen?

Archive - Originally posted on "The Horse's Mouth" - 2015-02-09 06:24:52 - Graham Ellis

Very few of them, it would seem, are overweight and many are worryingly thin - rather a different situation you'll find in the UK / US population as a whole. Under a body - mass index (BMI) of around 18 to 20, people are considered to be underweight - and taking a data file of online data, I can calculate ...
14.87 Amber Valletta
14.94 Calista Flockhart
15.28 Carmen Kass
15.30 Shannon Elizabeth
15.37 Taylor Swift

Over 25 (or over 30 for bodybuilders and people of similar stature) and you're considered overweight. Let's see some of the chunkier stars:
26.29 Ben Stiller
27.06 Brad Pitt
27.89 Bruce Willis
29.30 Vin Diesel
31.00 Sylvester Stallone
35.96 Hulk Hogan

Body Mass Index (the slightly out of date way) is calculated as weight (in Kgs) upon the height (in metres) squared - and it's a regular exercise on our courses to have people write programs to work this out. In the case of the Java course I ran last week, I had my delegates reading this data from a file and the create Person objects from which the BMI could be extracted. That was - for future use - the algorithm's hidden with in ("encapsulated") in the class, and the future user only needs to know what to pass in and what's returned, and not how the work's actually done.

The example also illustrates:
• the use of the Compatable Interface (implememts Comparable) for sorting
• the use of a Vector to allow the program to dynamically allocate memory to suite the input file size
• the use of a factory design pattern to convert a text record into an object
• cacheing of calculation results to avoid repeated re-application of algorithms in an object
• for training purposes, a usage counter to see how many times a method was called
• trapping of erroneous data lines and flagging the errors to an error channel (System.err)
Source code [here]. Raw data [here].