Pascal Program
Posted by Samath
Last Updated: March 20, 2012
Program Trinbarjam;

varĀ 
Candidates:string;
Num: integer;
count:integer;
name:array [1..4] of string;
party: array [1..4] of string;
votes: array [1..4] of integer;
Hivotes: integer;
Hiname:string;
PDRtotal:integer;
WNATotal:INTEGER;
UPMTotal:INTEGER;
DAPTotal:INTEGER;
WinningPartyVotes: integer;
Hiparty:String;

begin

PDRtotal:= 0;
WNATotal:= 0;
UPMTotal:= 0;
DAPTotal:= 0;
WinningPartyVotes:= 0;

writeln('Enter the constituency name');
readln (Candidates); {constituency name}

writeln('enter the number of candidates');
readln(num); {number of candidates}

while num <> 0 do
begin

for count := 1 to num do
beginĀ 
writeln ('enter candidate name');
readln (name[count]); {Candidate name}

Writeln('Enter party acronym');
readln (party[count]); {Candidate party}

writeln ('Enter the number of votes received');
readln (votes[count]); {Candidate Votes}

if votes[num] > Hivotes then
begin
Hivotes := votes[count]; {Winner number of votes}
Hiname := name[count]; {Winner Voter Name}
Hiparty:= party[count]; {Winner party}
end;

if party[count] = 'PDR' then
begin
PDRTotal:= PDRTotal + votes[count]
end;

if party[count] = 'WNA' then
begin
WNATotal:= WNATotal + votes[count]
end;

if party[count] = 'UPM' then
begin
UPMTotal:= UPMTotal + votes[count]
end;

if party[count] = 'DAP' then
begin
DAPTotal:= DAPTotal + votes[count]
end;


if PDRTotal > WinningPartyVotes then
begin
WinningPartyVotes := PDRTotal;
end;

if WNATotal> WinningPartyVotes then
begin
WinningPartyVotes := WNATotal;
end;


if UPMTotal> WinningPartyVotes then
begin
WinningPartyVotes := UPMTotal;
end;


if DAPTotal > WinningPartyVotes then
begin
WinningPartyVotes := DAPTotal;
end;

end;

writeln('enter the number of candidates in the constituency or Enter STOP to end the program');
readln(num);



end;
writeln('The winning party is', Hiparty);
writeln ('The Wining Candidate is:', Hiname);


end.

Related Content