Issue
Let's say I have 6 options and 4 people that can choose any of these options.
there are 4 variables (int) one for each person, they can choose one option.
two or more people can select the same option.
how can I count how many times each option has been selected without doing a bunch of if statements?
Also, I'm not allowed to use data structures.
Solution
You could store the answers using primes p_1 to p_6. An unique prime p for each option. You start with a 'memory' integer m. Each time an user u selects an option i you multiply your 'memory' int with the corresponding option prime m = m* p_i. At any given time you can find selected options as the prime decomposition of m. This approach does not allow you to recover the order of the choices though. If that is important too you could alternatively code the user with the primes and their answers with as the factors m= p_1^(option user 1) * p_2^(option user 2) * ... * p_n ^(option user n). Anyway your choice depends a bit on what you want to do with the answers and whether you want to introduce more users or rather more options. I hope this might put you in a useful direction for you assignment.
Answered By - Nick
Answer Checked By - Marie Seifert (JavaFixing Admin)