- #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:
Please tell me if this is correct.
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: