CS 1401, Quiz 4 (based on Test 1), TR version

Date: Thursday, September 26, 2013
Name (please type legibly, ideally in block letters): ______________________________________________________________________

3. One of the reasons for the US census is allocating federal funds, including federal funds for public health. One of the big problems with public health in the US is the increasing fraction of overweight people, in particular, overweight children. Whether a child is overweight or not is determined by the Body Mass Index which is computed as follows:

         mass (in pounds)
 BMI  = ---------------------- X 703
         (height (in inches))2
Assuming that mass and height are already placed in the corresponding variables of type double, write a Java code statement for assigning the corresponding value to the variable bmi of type double. Explain, step-by-step, which arithmetic operations will be performed first, which next, etc. Explain what happens if you do not use parentheses to describe a denominator.

6. Suppose that after graduation, and get a job with the US Census Bureau in Washington, DC. The number of people in El Paso county will thus decrease by 1. If this number of people is stored in two integer variables people and personas, which of the two lines of code leads to a correct decrease of both values: If originally, before each line, we had 800,000 people, explain what will happen after each of these lines is implemented by Java. What is a clearer way (different from those above) to decrease the values to the two variables?