### Program Development

There are several full length programs in the book. I would like you to write (copy) these pieces of code and get them to run. Each program will be in a file by itself with .java extension. Your code must have the following template:

```/*

File:

Description:

Name:

Date:

*/
```
You must make sure that the following programs run as shown in the book.
• Listing 2.1: ComputeArea.java
• Listing 2.2: ComputeAreaWithConsoleInput.java
• Listing 2.3: ComputeAverage.java
• Listing 2.4: DisplayTime.java
• Listing 2.5: FahrenheitToCelsius.java
• Listing 2.6: ShowCurrentTime.java
• Listing 2.7: SalesTax.java
• Listing 2.8: ComputeLoan.java
• Listing 2.10: ComputeChange.java

After you have made sure that all the programs run on the command line, zip all the file stogether into a single file called:

```myuteid_chap_2.zip
```
Substitute your UT EID for the place holder myuteid in the file name. Upload the zip file to the turnin system. Do not upload the files individually. We must receive the zip file by 11 PM on Wednesday, 26 June 2013.

### Is this an Algorithm?

Lynne and Calvin are trying to decide who will take the dog for a walk. Lynne suggests that they flip a coin and pulls a quarter out of her pocket. Calvin does not trust Lynne and suspects that the quarter maybe weighted (meaning that it might favor a particular outcome when tossed) and suggests the following procedure to fairly determine who will walk the dog.

1. Flip the quarter twice.
2. If the outcome is heads on the first flip and tails on the second, then I will walk the dog.
3. If the outcome is tails on the first flip, and heads on the second, then you will walk the dog.
4. If both outcomes are tails or both outcomes are heads, then we flip twice again.
Calvin's technique is an algorithm.
a) True
b) False.
You do not have to submit this answer.

### Write Algorithms for these Problems

You do not have to submit these answers.

1. How would you add a list of numbers on the computer?
2. How would you find the largest number in a list of numbers without sorting?
3. How would you find the number of occurrences of a given number in a list of unsorted numbers? You may sort if want to.

### Number Conversions

You do not have to submit these answers.

1. Convert the following numbers in decimal to 8-bit 2's complement binary: 28, -39
2. Write the binary equivalent of all numbers from 0 to 15 in 4-bit binary.
3. These are 8-bit 2's complement binary. What decimal numbers do they represent?
• 0110 1100
• 1111 1111
• 1000 0000
• 0111 1111
4. The hexadecimal number B4 is a 2's complement number in 8-bit binary. Convert it to decimal.