I’m working on a program to generate fraction arithmetic problems, in particular where the student can choose which operation(s) they’d like to focus on. Right now I have a pulldown menu with each of the four arithmetic operations selectable, and then an “all” selection where the program will use any of the four arithmetic operations at random. What I’d like to do is have checkboxes for addition, multiplication, etc. in the manipulate pane, and then have the checked boxes define which operations the program “allows” when it build problems. I can think of a couple of “brute force” ways to do this, like listing every possibility of checked boxes in a Which command, but I feel like there must be a better way…
I’m not sure if I exactly understand the problem. Here is my example which probably isn’t the best code. Note that I make the numbers into strings to prevent evaluation, which is a bit of a hack:
This function takes a list of operations like {Times, Plus, Subtract} , produces three random integers and inserts a random operation inbetween them. I’ve used the infix notation using the tilde (~) which might be a bit confusing if you haven’t seen it before.
Note I wrote this function and tested it before writing any user interface. For most projects, don’t worry about the user interface until you have functions that do the calculations you want. This separates your programming problem up into easier parts.
Once I had this function, I wrote a Manipulate like this: