Ahaan

FRQ 1 Homework 2024

FRQ 1 Homework 2024

Proof of Completion and Running on Open Coding Society Code Runner Part A

Proof of Completion and Running on Open Coding Society Code Runner Part B

Key Takeaways

  1. Use Math.random() for Probability: Generate random events by checking if Math.random() < probability (e.g., < 0.05 for 5% chance).

  2. Random Range Formula: To get a random int from min to max inclusive, use (int)(Math.random() * (max - min + 1)) + min.

  3. Protect Against Negative Values: Use Math.max(0, value) or an if-check to prevent variables from going below zero.

  4. Loop with Early Exit: Use break to exit a loop early when a condition is met (like running out of food).

  5. Counter Pattern: Track occurrences by incrementing a counter variable inside a loop before processing.

Area of Stuggle

An area of struggle for me is using the correct syntax when writing my code. I will have the correct idea on how to write the correct code, by planning out a pysudocode verison in my head and then thinking about how that would be written in Java. I understand how to write the code but, sometimes I make mistakes with my syntax which happened many times for example forgetting semicolon, incorrect bracket, didn’t indent correctly. These errors caused the code runner to have an error and it allowed me to debug. This is something i should work on fixing and improving, so I get better with avoiding syntax errors on AP Exam.

Scroll to top