|Share this thread:|
Jan25-12, 03:10 PM
Develop an algorithim or write pseudocode to determine the winning candidate for a constiuency in the national elections. The algorithim must accept as input the names of the four candiddates and the number of votes each candidate receives. The succesful candidate is one who receieved the most votes.
Print the name of the winner and the number of votes he/she receieved.
Design and execute a trace table that accepts vote data at a polling station in a constiituency. Data should include special votes,general(valid) votes and spoilt votes. Votes should be cast for anyone of four parties, DAP,WNA,UPM or PDR. The table should trace the increment of each vote category and determine which party secured the majority of votes. The table should have at least ten iterations and should end when a specific value is entered.
Declare: winning_cand,cand1,cand2,cand3,cand4 ---> string
Print("enter four names")
Print("enter number of votes")
if (vote1 > vote 2) and (vote1 > vote3) and (vote1 > vote 4) then
print("The winner is cand1 with vote1")
if (vote2 > vote 1) and (vote2 > vote3) and (vote2 > vote 4) then
print("The winner is cand2 with vote2")
if (vote3 > vote 1) and (vote3 > vote2) and (vote3 > vote 4) then
print("The winner is cand3 with vote3")
if (vote4 > vote 1) and (vote4 > vote2) and (vote4 > vote 3) then
print("The winner is cand4 with vote3")
My teacher said my pseudocode was wrong and I should use a while loop, and I think I need more variables , could someone please assist me?
|Register to reply|
|Pseudocode help||Engineering, Comp Sci, & Technology Homework||26|
|Need a little help with pseudocode||Engineering, Comp Sci, & Technology Homework||4|
|Pseudocode help||Engineering, Comp Sci, & Technology Homework||45|
|Pseudocode Help||Engineering, Comp Sci, & Technology Homework||1|