Reference: https://apcentral.collegeboard.org/media/pdf/ap24-frq-comp-sci-a.pdf
Topics:
Random # Generator
Conditionals
Objects - Instance Variable Update
Loops - while + counter
Good project for Objects unit
NOT a good graded assignment - Due to the nature of randomization, you can't build test cases for this program.
Memorize a function that allows you to quickly generate random #'s.
//This function generates a random # from low to high (inclusive).
//This is the only function I ever use for generating random #'s.
public static int random_range(int low, int high)
{
int size = high - low + 1;
return (int)(Math.random() * size)+low;
}
This problem requires you to use random #'s in multiple ways
95% chance (normal condition) of feeding the birds
5% chance (abnormal condition) of feeding the bear
Amount of food birds eat is random (kind of)
Though this is a simulation, there's something to be said about cutting the simulation early. If you know the bear ate all the food, but there's still 4 days left in the simulation, do you need to keep running it?
The documentation provides you with example scenarios. Use those in the main method to test your program. Due to randomization, you likely won't get the exact same results, but your program should function the same way.