## CS 1401, Exam #1, 9:30 am version

Date: Friday, September 21, 2007
Name (please type legibly, ideally in block letters): ______________________________________________________________________

1. History of computing:
(a) How did the invention of zero helped computing?
(b) Briefly describe the contribution of ancient Egyptians to computing.
(c) For extra credit: describe one more event from the history of computing.

```

```
2. Fall is coming soon, so this weekend is a good time for the last summer barbecues. To organize a big BBQ, students need to rent a big grill, and to buy enough food and drinks for everyone. Describe, step-by-step, an algorithm that would allow to compute how much we need to collect from each student to cover the costs. As part of this algorithm, you should ask for the cost of renting the grill, and the cost of food and drinks per student. For example, if renting a grill costs \$20, the food for each student costs \$3, and the drinks \$2, then the cost of the party for 20 students is \$20 + 20 * (\$3 + \$2) = \$120. Thus, each student has to pay \$120 / 20 = \$6.
```

```
3. 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"):
• Last Day of Summer

• LastDayOfSummer!

• LastDayOfSummer

• int

• costsMe\$6

```

```
4-5. Write a main method that asks a person for the cost of renting a big grill, the cost of food per student, the cost of drinks per student, the number of students, and the name of the contact person, and then computes and prints the statement:
```Dear (name here),

For your barbecue party, you need to collect \$(amount) per student.
```
(Do not worry about formatting the amount.) For example, if Roberto Araiza is a contact person for the party of 20 in which renting a grill costs \$20, the food for each student costs \$3, and the drinks \$2, then each student has to pay \$6, so the computer should print:
``` Dear Roberto Araiza,

For your barbecue party, you need to collect \$6.00 per student.
```

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

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

```

```
6. Students decided to extend a good tradition of fortune cookies to the BBQ party. To make individual fortune statements, write down a line of code that, given a string name (that contains the name of the person who will receive this cookie), places the message "Dear (name here), you will do very well on Test 1!" into a string message. For example, for a student whose name is Vladik, the contents of the string message should be "Dear Vladik, you will do very well on Test 1!".