Shoppers at a mall were asked whether they preferred wearing gloves or mittens in cold weather. Shoppers’ preferences were stored in the list voteList as strings, with the string "Gloves" representing a preference for gloves and the string "Mittens" representing a preference for mittens.
The following code segment is intended to traverse the list and display the number of shoppers who chose gloves and the number of shoppers who chose mittens.
numGlovesVotes
0
numMittensVotes
0
{
IF(vote = "Gloves")
{
numGlovesVotes
numGlovesVotes + 1
}
ELSE
{
numMittensVotes
numMittensVotes + 1
}
}
DISPLAY(numGlovesVotes)
DISPLAY(" shoppers chose gloves and")
DISPLAY(numMittensVotes)
DISPLAY(" shoppers chose mittens.")
Which of the following should replace so that the code segment works as intended?
Responses
IF(vote ≤ LENGTH(voteList))
IF(vote ≤ LENGTH(voteList))
FOR EACH vote IN voteList
FOR EACH vote IN voteList
REPEAT LENGTH(voteList) TIMES
REPEAT LENGTH(voteList) TIMES
REPEAT UNTIL(vote > LENGTH(voteList))