so here's the deal. I'm trying to write a millionare quiz in Mathematica. Now, this has been already done in other coding languages, specifically I've seen it done in C here:
http://tausiq.wordpress.com/2009/10/02/millionaire/
So, the setup is that I just input answers for the questions, then input the correct answers, and the function/program gives me the amount the player has earned. Now, the problem says to include the 1000 and $32000 save points, but it isn't all that necessary.
Now, I want to translate this into Mathematica, but I can't seem to find how this would work. I was thinking of maybe using two lists, one with the answers of the user and the second with the correct answers and to somehow compare them. Can this be done with just the if, switch and for commands?
Can anyone help me with this?
EDIT:
Here's what I've done so far
A = {a, b, c, d, a, b, c, d, a, b, c}; B = {a, b, c, d, a, b, c, a, a, b, a};
This is how I read the answers and everything. Now I compute how many are correct:
For[i = 1; j = 0, A[[i]] == B[[i]], i++, 1; j++]
Then, based on the number I get I print out the amount they have won:
t2[k_] := Switch[k, 1, Print[100 KM], 2, Print[200 KM], 3, Print[300 KM], 4, Print[500 KM], 5, Print[1000 KM], 6, Print[2000 KM], 7, Print[4000 KM], 8, Print[8000 KM], 9, Print[16000 KM], 10, Print[32000 KM], 11, Print[64000 KM], 12, Print[125000 KM], 13, Print[250000 KM], 14, Print[500000 KM], 15, Print[1000000 KM]]
t2[j]
Or I use the code given by Pickett:
f1[n_] := Which[n <= 3, Print[100 n, " KM"], n <= 11, Print[500 2^(n - 4), " KM"], 12 <= n, Print[125000 2^(n - 12), " KM"]]
Now I only need to implement somehow the check for the safe points. I can use the second function given by Pickett:
f2[n_] := Which[n >= 10, 32000, n >= 5, 1000, True, 0]
but don't really know how to implement them both to have a check and then to be given the correct amount. I assume that I should somehow use the third function, but honestly I don't know how.