## CS 1401, Exam #1, MW 9-10:20 version

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

1. On September 18, 1793, the first cornerstone for the Capitol building was laid by George Washington. Once the building was built, this became a place where the results of US censuses were reported and discussed.

• Explain what Hollerith did to help process the census results, and how this promoted computations in general.
• Name US researchers who pioneered the design of modern computers, briefly explain their contributions.
For extra credit: describe one more event from the history of computing.

```

```
2. For each of the following sequences of symbols, describe which can be valid Java identifiers and which cannot be; if you believe they cannot be, briefly explain why (e.g., "is a reserved word" or "does not start with a letter"):
• 9-10:20session

• session9-10:20

• static

• census

• session_9_10_20

```

```
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.

```

```
4-5. Suppose that the federal funds provide \$5.00 per resident for public health expenses. Write the main method which asks the user for the name of the county, asks how many people live in the county, and prints a memo describing how much funds will go to the county. For example, if we want to know how much money will go to El Paso County with 800,000 residents, your program should print the following message:
```From: U.S. Census Bureau

El Paso County with 800000 residents will get
\$5.00 X 800000 = \$4000000.00.
```
Declare 5.00 as a constant of type double, so that it will be easy to change if needed.

Reminder: to read from the keyboard, you can define the reader as follows:

```Scanner reader = new Scanner(System.in);
```
the header of the main method is:
```public static void main(String[] args){
```
```

```
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:
• people = personas--;
• people = --personas;
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?