# FRQ Style Selection Coding 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.

In the following exercises which are similar to the Free Response Questions (FRQs) in the AP exam, you will write code inside a method with parameters and return values. Make sure that you use the parameter variables given in the method header and return a value.

```java
public static return-type method-name(param-type param-var1, param-type param-var2, ...)
{
    // ADD CODE HERE using the param-variables //
    return result;
}
```

## Exercise 1

Create the method `front_back(str, start, end)` that takes three strings and returns a string based on the following conditions.

- If `str` contains `start` at the beginning and `end` at the end then return `"s_e"`.
- If `str` contains `start` at the beginning of the string return `"s"`.
- if `str` contains `end` at the end of the string return `"e"`.
- Otherwise return `"n"`.

| Example Input | Expected Output |
| --- | --- |
| `front_back("Open at noon", "Open", "noon")` | `"s_e"` |
| `front_back("Opening time", "Open", "noon")` | `"s"` |
| `front_back("Afternoon", "Open", "noon")` | `"e"` |
| `front_back("Closed", "Open", "noon")` | `"n"` |
| `front_back("It is noon now", "open", "noon")` | `"n"` |

> Open the `01-front-back-written` folder and edit `FrontBack.java`. Press **Run** to try it; **Run Tests** checks it (2 tests).

## Exercise 2

The squirrels in Palo Alto spend most of the day playing. In particular, they play if the temperature is between 60 and 90 (inclusive). Unless it is summer, then the upper limit is 100 instead of 90. Given an `int temperature` and a `boolean isSummer`, return `true` if the squirrels play and `false` otherwise.

| Example Input | Expected Output |
| --- | --- |
| `squirrelPlay(70, false)` | `true` |
| `squirrelPlay(95, false)` | `false` |
| `squirrelPlay(95, true)` | `true` |

> Open the `02-squirrelPlay-written` folder and edit `SquirrelParty.java`. Press **Run** to try it; **Run Tests** checks it (1 test).

## Exercise 3

Given a `day` of the week encoded as 0=Sun, 1=Mon, 2=Tue, …6=Sat, and a `boolean` indicating if we are on `vacation`, return a string of the form `"7:00"` indicating when the alarm clock should ring. Weekdays, the alarm should be `"7:00"` and on the weekend it should be `"10:00"`. Unless we are on vacation – then on weekdays it should be `"10:00"` and weekends it should be `"off"`.

| Example Input | Expected Output |
| --- | --- |
| `alarmClock(1, false)` | `7:00` |
| `alarmClock(5, false)` | `7:00` |
| `alarmClock(0, false)` | `10:00` |

> Open the `03-alarmClock-written` folder and edit `VacayAlarmClock.java`. Press **Run** to try it; **Run Tests** checks it (1 test).

## Exercise 4

You and your date are trying to get a table at a restaurant. The parameter `you` is the stylishness of your clothes, in the range 0..10, and `date` is the stylishness of your date’s clothes. The result getting the table is encoded as an int value with 0=no, 1=maybe, 2=yes. If either of you is very stylish, 8 or more, then the result is `2` (yes). With the exception that if either of you has style of 2 or less, then the result is `0` (no). Otherwise the result is `1` (maybe).

| Example Input | Expected Output |
| --- | --- |
| `dateFashion(5, 10)` | `2` |
| `dateFashion(8, 2)` | `0` |
| `dateFashion(5, 5)` | `1` |

> Open the `04-dateFashion-written` folder and edit `DateStylishness.java`. Press **Run** to try it; **Run Tests** checks it (1 test).
