# Selection Toggle Code Practice (2.1-2.6)

Each coding exercise has its own folder. Open its `.java` file and press **Run** to try it. **Run Tests** checks every graded exercise in this lesson at once.

For each of the coding problems below, write your own solution.

## Exercise 1

Write code that tests guess to see if it is equal to answer or too high or too low. If it is too high as in the example below, it should print out `Your guess is too high`.

> Open the `01-u2a-toggle1` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (4 tests).

## Exercise 2

Write code that prints `You can go out` if you don’t have any homework and have cleaned and otherwise prints `You can not go out`.

> Open the `02-u2a-toggle2` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (3 tests).

## Exercise 3

Write code that tests if x is between 1 and 10, and prints `1 <= x <= 10` or `x is not in range`.

> Open the `03-u2a-toggle3` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (4 tests).

## Exercise 4

Write code that prints out if the string `message` has the word `ringing` in it or not. It should print out `Answer the phone!` if `ringing` is in `message`, and `I don't hear anything.` if not.

> Open the `04-u2a-toggle4` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (3 tests).

## Exercise 5

Write code that prints if your favorite food is junk food (pizza or wings) or not. Your code should check to see if the variable `favFood` value is `pizza` or `wings`. If it is, it should print out `Your fav is junk food`. If not, it should print `Your fav is not junk`.

> Open the `05-u2a-toggle5` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (3 tests).

## Exercise 6

Write code that prints your fine if you are speeding. If you are going over 65 but less than 75, the fine is `50`. If you are going at least 75 and less than 85, the fine is `100`. Over that the fine is `200`. It should not print anything if you are not speeding.

> Open the `06-u2a-toggle6` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (3 tests).

## Exercise 7

Write code that prints the alarm time. If it is a weekday you should get up at `7:00am` and if not get up at `10:00am`.

> Open the `07-u2a-toggle7` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (4 tests).

## Exercise 8

Write code that prints if you `Can text now` or `Can't text now`. You can text if you are not driving and not eating.

> Open the `08-u2a-toggle8` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (4 tests).

## Exercise 9

Write code that prints whether your name `Starts with a vowel` (a, e, i, o, u) or `Starts with a consonant`.

> Open the `09-u2a-toggle9` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (3 tests).

## Exercise 10

Write code that prints the letter grade with your score. For a score greater than 90, it should print `A`. For a score between 80 and 90, it should print `B`. For a score between 70 and 80, it should print `C`. For a score between 60 and 70, it should print `D`. For all other scores, it should print `E`.

> Open the `10-u2a-toggle10` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (4 tests).

## Exercise 11

Complete the `get_mid(str)` method in the `StringWorker` class to return the middle character if the string has an odd number of characters and the middle two characters if the string has an even number of characters. For example, `get_mid("way")` should return `"a"` and `get_mid("away")` should return `"wa"`.

> Open the `11-u2a-toggle11` folder and edit `StringWorker.java`. Press **Run** to try it; **Run Tests** checks it (2 tests).
