Design & Execute Trace Table for Polling Station Votes

  • Thread starter lionely
  • Start date
In summary: Well, in this pseudocode, there is no provision for entering the actual vote counts. This pseudocode only counts the votes. You would have to enter the votes somewhere else, and that code would have to input the votes and call this code to count the votes.
  • #1
lionely
576
2
Design and execute a trace table that accepts vote data at a polling station in a constituency. 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.

Attempt:

Code:
START
Declare: Class,: string
Party,D_General,W_General,U_General,P_General,D_Spoil,W_Spoil,U_Spoil, P_Spoil, W_Special, U_Special, P_Special, D_Special:integer

PRINT “Enter JNP for Party or Class to Quit”
PRINT “Enter Party”
Read Party
PRINT “Enter Class of Vote”
Read Class
	WHILE(Party <> “JNP” OR Class <> “JNP”) DO
	If (Class = “Special”) THEN	
	IF (Party = “DAP”)THEN
	D_Special =D_Special + 1
	ENDIF
	IF (Party = “WNA”) THEN
	W_Spec ial = W_Special + 1
	ENDIF
	IF(Party = “UPM”)THEN
	U_Special = U_Special + 1
ENDIF
IF(Party= “PDR”)THEN
P_Special = P_Special+1
ENDIF
ENDIF

If (Class = “General”) THEN	
		IF (Party = “DAP”)THEN
		D_ General =D_ General + 1
		ENDIF
		IF (Party = “WNA”) THEN
		W_ General = W_ General + 1
		ENDIF
		IF(Party = “UPM”)THEN
		U_ General = U_ General + 1
ENDIF
IF(Party= “PDR”)THEN
P_ General = P_ General +1
ENDIF
ENDIF

		If (Class = “Spoil”) THEN	
		IF (Party = “DAP”)THEN
		D_ Spoil =D_ Spoil + 1
		ENDIF
		IF (Party = “WNA”) THEN
		W_ Spoil = W_ Spoil + 1
		ENDIF
		IF(Party = “UPM”)THEN
		U_ Spoil = U_ Spoil + 1
ENDIF
IF(Party= “PDR”)THEN
P_ Spoil = P_ Spoil +1
ENDIF
ENDIF
ENDwhile

STOp

Please tell me if this is correct.
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
I don't think this is right, but then again, the problem statement is not clear to me. For example, what is the difference between special votes and general (valid) votes? How can you tell if a vote is spoiled?

What is a trace table? Is that something you use to simulate the execution of the code for a specific input value?

Your pseudocode doesn't give any way for a user to enter a vote.

The problem statement suggests that there should be a loop of some kind, and should do input.
The table should have at least ten iterations and should end when a specific value is entered.
You have an endwhile statement, but there is no while statement.
 
  • #3
Oh my gosh I forgot a half of the code...

I'll edit my previous post and post the whole code.
 
  • #4
A tracetable is a way of testing a pseudocode. But I don't need help witht he tracetable I need help with the pseudocode.
 
  • #5
lionely said:
Design and execute a trace table that accepts vote data at a polling station in a constituency. 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.

Attempt:
I can see that you put some effort into indenting the various statement, but your indentation was not as good as it could be. I have taken the liberty of indenting your code as I would do it.
Code:
START
Declare: Class,: string
Party,D_General,W_General,U_General,P_General,D_Spoil,W_Spoil,U_Spoil, P_Spoil, W_Special, U_Special, P_Special, D_Special:integer

PRINT “Enter JNP for Party or Class to Quit”
PRINT “Enter Party”
Read Party
PRINT “Enter Class of Vote”
Read Class
WHILE(Party <> “JNP” OR Class <> “JNP”) DO
   If (Class = “Special”) THEN	
      IF (Party = “DAP”)THEN
         D_Special =D_Special + 1
      ENDIF
      IF (Party = “WNA”) THEN
         W_Spec ial = W_Special + 1
      ENDIF
      IF(Party = “UPM”)THEN
         U_Special = U_Special + 1
      ENDIF
      IF(Party= “PDR”)THEN
         P_Special = P_Special+1
      ENDIF
   ENDIF

   If (Class = “General”) THEN	
      IF (Party = “DAP”)THEN
         D_ General =D_ General + 1
      ENDIF
      IF (Party = “WNA”) THEN
         W_ General = W_ General + 1
      ENDIF
      IF(Party = “UPM”)THEN
         U_ General = U_ General + 1
      ENDIF
      IF(Party= “PDR”)THEN
         P_ General = P_ General +1
      ENDIF
   ENDIF

   If (Class = “Spoil”) THEN	
      IF (Party = “DAP”)THEN
         D_ Spoil =D_ Spoil + 1
      ENDIF
      IF (Party = “WNA”) THEN
         W_ Spoil = W_ Spoil + 1
      ENDIF
      IF(Party = “UPM”)THEN
         U_ Spoil = U_ Spoil + 1
      ENDIF
      IF(Party= “PDR”)THEN
         P_ Spoil = P_ Spoil +1
      ENDIF
   ENDIF
ENDwhile

STOp

Your logic for exiting the while loop is not correct. The idea is supposed to be that when you enter JNP for party or vote, the loop doesn't run. Suppose you're running this, and are prompted to enter the party, and you type "JNP" and for Class you just press the ENTER key. The expression Party <> "JNP" is false, and the expression Class <> "JNP is true, so the expression Party <> “JNP” OR Class <> “JNP” is (false OR true), which is true, so the loop runs again.

To fix this, change "OR" to "AND".

Also, in this line
Code:
Declare: Class,: string
you have an extra comma.
 
  • #6
Oh, but the thing is I had a doubt with this pseudocode because if this was a polling station if the special votes were like 200 wouldn't I have to enter somethign 200 times?
 

1. How do you design a trace table for a polling station vote?

To design a trace table for a polling station vote, you will need to identify the variables and the steps involved in the voting process. These variables could include the voter's name, the candidate they are voting for, and the number of votes received by each candidate. The steps involved would include checking the voter's identification, marking the vote, and tallying the votes at the end of the day. The trace table will help you keep track of the data and ensure accuracy in the voting process.

2. What is the purpose of a trace table in a polling station vote?

The purpose of a trace table in a polling station vote is to track the flow of data and ensure that the voting process is carried out accurately. It helps in identifying any errors or discrepancies in the votes and ensures transparency in the election process.

3. How do you execute a trace table for a polling station vote?

To execute a trace table for a polling station vote, you will need to follow the steps outlined in the design phase. This includes tracking the variables and steps involved in the voting process and recording the data accurately. You will also need to ensure that the trace table is updated in real-time to reflect any changes or updates in the voting process.

4. What are the benefits of using a trace table for a polling station vote?

Using a trace table for a polling station vote has several benefits, including ensuring accuracy in the voting process, identifying any errors or discrepancies, and providing transparency in the election process. It also helps in keeping track of the data and ensures that the votes are counted correctly.

5. How can you ensure the accuracy of a trace table for a polling station vote?

To ensure the accuracy of a trace table for a polling station vote, it is essential to regularly update and cross-check the data recorded in the table. This can be done by having multiple individuals involved in the data recording process and conducting regular audits to identify any errors or discrepancies. It is also crucial to follow the trace table design accurately and make any necessary adjustments as needed.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
Back
Top