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.zipSubstitute your UT EID for the place holder

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.

- Flip the quarter twice.
- If the outcome is heads on the first flip and tails on the second, then I will walk the dog.
- If the outcome is tails on the first flip, and heads on the second, then you will walk the dog.
- If both outcomes are tails or both outcomes are heads, then we flip twice again.

a) True

b) False.

You do not have to submit this answer.

You do not have to submit these answers.

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

You do not have to submit these answers.

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

- The hexadecimal number B4 is a 2's complement number in 8-bit binary. Convert it to decimal.
- Add 3D and F5 and express the answer in octal.
- Add 517 in octal to 3A in hexadecimal and express the answer in decimal. [Hint convert both numbers to binary and add.]
- Add the following 2's complement 8-bit numbers: 1011 1001 and 1110 0110. Ignore the overflow bit. Express the answer in decimal.