       looping

• To: mathgroup at smc.vnet.net
• Subject: [mg106704] looping
• From: glenn kuhaneck <mcguyver128 at yahoo.com>
• Date: Thu, 21 Jan 2010 04:55:25 -0500 (EST)

```this code is supposed to randomly select a student from a list, keep track of how many times he/she has been called, and how many answers they have gotten correct.

I am having problems getting the following code to repeat on request: i have tried do loops, while loops, and labels none have worked.   please help

These are the sample lists I am using for the code below
name = ( {
{"apple"},
{"bob"},
{"cat"},
{"dog"},
{"ear"},
{"frog"},
{"greg"},
{"hippo"},
{"i9"},
{"joe"}
}); score = ({
{0},
{0},
{0},
{0},
{0},
{0},
{0},
{0},
{0},
{0}
}); called = ({
{0},
{0},
{0},
{0},
{0},
{0},
{0},
{0},
{0},
{0}
}); prcnt = ( {
{0},
{0},
{0},
{0},
{0},
{0},
{0},
{0},
{0},
{0}
} );

this is the code to manipulate the lists created above
repeat = "yes";
c = "wrong";
l = Length[name];
n = RandomInteger[l - 1] + 1;

Label[begin]
"Student #"
n
name[[n]]
called[[n]] += 1;
"# times called"
called
"Old Score"
score
Input["Was the answer correct?", Button["Yes", c = "Right"]];
If[c == "Right", score[[n]] += 1]; c
"New Score"
score
score[[n]]
prcnt[[n]] = score[[n]]/called[[n]]
"Class %"
prcnt
Input["Another ?", Button["No", repeat = "no"]];
If[repeat == "yes", Goto[begin], Goto[end]];
Label[end];
prcnt[[n]]