Asked by Anonymous
Sarah and Jane are running for Student Council President. Write a pseudocode algorithm that will collect ‘S’ or ‘J’ from a voting pool of 51 students. Tally the votes for each candidate and print the winners Name along with the total number of votes received.
Answers
Answered by
oobleck
s=0
j=0
for i=1..51
read vote
s++ if vote == "S"
j++ if vote == "J"
next i
print (s>j) ? "Sarah "+s : "Jane "+j
j=0
for i=1..51
read vote
s++ if vote == "S"
j++ if vote == "J"
next i
print (s>j) ? "Sarah "+s : "Jane "+j
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.