There is a more recent offering of this course. This is an archive of the
course which was offered in Fall 2017.
SE1011
Class Exercises
Week 5 Lecture 2 Class Exercises
## Exercise 1: Packages
1. Individually write an explanation for the purpose of a Java package.
2. When you and your partner have both completed your answers, compare them and determine which answer you like better (and why).
3. Write a new an improved answer together.
## Exercise 2: Coding Conventions
1. Individually write an explanation for the purpose of a coding convention.
2. When you and your partner have both completed your answers, compare them and determine which answer you like better (and why).
3. Write a new an improved answer together.
4. List the main areas that the [coding standards](CodingStandard) document addresses.
5. List important coding conventions that you need to be aware of as you continue writing code this year.
## Exercise 3: Random Numbers
Using documentation for the [java.util.Random](http://docs.oracle.com/javase/8/docs/api/java/util/Random.html) class write code to generate random numbers with the following characteristics:
* An integer value between 0 and 15 (including 0, but no including 15)
* An integer value between 5 and 10
* A double value between 0.0 and 1.0
* A double value between 0.0 and 100.0
* A double value between -100.0 and 100.0
## Exercise 4 (optional): System.out.format
Using documentation for the [java.io.PrintStream.format](http://docs.oracle.com/javase/8/docs/api/java/io/PrintStream.html#format(java.lang.String, java.lang.Object...)) method and the [format string syntax](http://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html#syntax) make use of `System.out.format` to:
1. Display "**There are 8 chocolate bars each of the 5 bags**" where the numbers are stored in integers, `numBars` and `numBags`.
2. Display "**The COW JUMPED over the MOON**" where the all caps words are stored in strings: `noun1`, `verb`, and `noun2`.
3. Display "**The 8 COWs JUMPED over the MOON**" where the **8** is stored in an integer, `number`, and the all caps words are stored in strings: `noun1`, `verb`, and `noun2`.
4. Display PI with 5 significant digits.
5. Display five integers (each on a separate line) so that they are right justified, e.g.,
```
13
1872
8238820
3
-73
```
6. Display a table with a heading and three additional rows with the following format (assume all values come from variables):
```
Name Address
==== =======
John 123 8th St.
Wendy 231 3rd Ave.
Edwardo 321 Lethanderson Way
```
7. Display five doubles (each on a separate line) so that they are right justified and have 3 places to the right of the decimal, e.g.,
```
100.135
-3.700
70003.888
23.456
3.142
```