# Unit 3 FRQ
Hey everyone, this is Cunningham's TA!
I just graded all the submitted Unit 3 Progress Check FRQs and I just wanted to provide some general feedback. I did provide feedback through CollegeBoard to everyone individually, but there were a few common mistakes / reminders that I thought might be helpful to go over.
## General Reminders
- always read the directions (multiple times) before *and after* writing your solution
- understand what variables are already declared for you (you are almost always required to use these to get the point)
- if the directions don't ask you to print to stdout with `System.out.println`, don't (there is a point penalty for this)
- use the reference sheet
- if you are unsure about the name of a method, the arguments it takes, etc: check the reference sheet, it is there to help you
- all the required Java classes are on the reference sheet
- find it [here](https://apstudents.collegeboard.org/ap/pdf/ap-computer-science-a-java-quick-reference_0.pdf)
- remember your code is being read by a human, not a computer
- if you are declaring variables or functions, use descriptive and meaningful names
- don't declare new variables if you don't have to; unnecessary variables overcomplicate your code and can result in a point penalty on the exam
## Question 1
### 1a
For the most part, the only issue people ran into on this one was not using the `rsvp` variable. Just make sure to read the question.
Here is the canonical solution:
```java=
if (rsvp) {
System.out.println("attending");
} else {
System.out.println("not attending");
}
```
### 1b
This question was also pretty good. If you did get this one wrong, just make sure your `if` / `else if` / `else` syntax is correct and you are using the `==` operator for comparisons.
Here is the canonical solution:
```java=
if (selection == 1) {
System.out.println("beef");
} else if (selection == 2) {
System.out.println("chicken");
} else if (selection == 3) {
System.out.println("pasta");
} else {
System.out.println("fish");
}
```
### 1c
This question asks you to store a string in a predeclared variable `option1`. Most solutions I graded looked like this:
```java=
if (rsvp) {
if (selection == 1) {
System.out.println("Thanks for attending. You will be served beef.");
} else if (selection == 2) {
System.out.println("Thanks for attending. You will be served chicken.");
} else if (selection == 3) {
System.out.println("Thanks for attending. You will be served pasta.");
} else {
System.out.println("Thanks for attending. You will be served fish.");
}
} else {
System.out.println("Sorry you can't make it.");
}
```
While the logic makes sense, it doesn't earn the point because it fails to store the string in the `option1` variable. The question was looking for something more like this:
```java=
if (rsvp) {
if (selection == 1) {
option1 = "Thanks for attending. You will be served beef.";
} else if (selection == 2) {
option1 = "Thanks for attending. You will be served chicken.";
} else if (selection == 3) {
option1 = "Thanks for attending. You will be served pasta.";
} else {
option1 = "Thanks for attending. You will be served fish.";
}
} else {
option1 = "Sorry you can't make it.";
}
```
### 1d
For this question, the most common mistake I saw was trying to compare the strings with the `==` operator.
```java=
if (option1 == option2) {
System.out.println(true);
} else {
System.out.println(false);
}
```
In Java, strings are objects. `String` variables store a pointer to the object in memory. When using `==` in this situation, you are actually comparing the memory addresses of the two pointers, which is not what we want to do. To compare the value of the string, we must use the `equals` method on a string instance. A correct comparison looks like this:
```java=
if (option1.equals(option2)) {
System.out.println(true);
} else {
System.out.println(false);
}
```
## Question 2
This question is genuinely very confusing. Just to reiterate my general advice above, read the question multiple times. Understand what the question wants you to do and the variables, classes, etc that it gives you. For me, drawing the question out on scratch paper really helps.
For reference, here is the canonical solution with my annotations:
```java=
// check if right side overflows & bound len
if (x + len > 10) {
len = 10 - x;
}
// check if bottom side overflows & bound len
if (y - len < 0) {
len = y;
}
Draw.drawLine(x, y, x + len, y); // top
Draw.drawLine(x + len, y, x + len, y - len); // right
Draw.drawLine(x + len, y - len, x, y - len); // bottom
Draw.drawLine(x, y - len, x, y); // left
System.out.println("side length = " + len + ", area = " + len * len);
```
These diagrams show the logical flow of the two if statments.


This diagram helps visualize the calls to `Draw.drawline`

## Conclusion
If you are unhappy with your score, don't worry too much about it. This is your first FRQ (and a difficult one at that).
If you have any questions, feel free to reach out and ask, I'm happy to help.
Mack :)