1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Pseudocode help

  1. Jan 25, 2012 #1
    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
    vote1,vote2,vote3,vote4,winning_vote----> integer
    Print("enter four names")
    read cand1,cand2,cand3,cand4
    Print("enter number of votes")
    read vote1,vote2,vote3,vote4

    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?
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you help with the solution or looking for help too?

Similar Discussions: Pseudocode help
  1. Matlab help (Replies: 0)

  2. Thermodynamics help (Replies: 0)

  3. Thermodynamics Help (Replies: 0)

  4. Radiation help (Replies: 0)

  5. Help with Matlab (Replies: 0)