Uploaded by Rihanna Sooknanan

Problem solving and program implemtation IT SBA Group 4 CB (1)

advertisement
IT Group 4
Problem Solving and Program Implementation
Jake Ramkelawan, Rihanna Sooknanan, Saim Ali, Ganesh Seeraj, Samir Mohammed
Problem Statement
Develop an algorithm to print the names of the candidates who should receive a
refund. A refund is due if the candidate’s votes received equals or exceeds 20 per
cent of the votes cast in the district. The algorithm should also determine and print
the number of candidates who received a refund. Test the algorithm with data from
five candidates. The algorithm must accept as input the names of the candidates,
District, votes received and the votes cast in the district. The algorithm should print
the name of the candidate and the words “Refund Due” or “No Refund” and the
number of candidates who received a refund. Data to test the algorithm must be
sourced from the spreadsheet section of the project.
PROBLEM SOLVING
1.Algorithm (Pseudocode)
1 BEGIN
2
COUNT = 0
3
FOR c = 1 to 5 DO
4
PRINT "Enter candidate name"
5
READ name
6
PRINT "Enter district name"
7
READ district
8
PRINT "Enter votes received"
9
READ vr
10
PRINT "Votes cast in district"
11
READ vc
12
IF vr >= (20/100 * vc) THEN
13
PRINT "Refund Due for ", name
14
COUNT = COUNT + 1
15
ELSE
16
PRINT "No Refund Due for ", name
17
END IF
18
END FOR
19
PRINT "Number of people who received a refund: ",COUNT
20 END
2. Trace table PUT DASHES FOR NONE CODE LIKE PRINT BEGIN AND END
Line
c
name
district
vr
vc
count
1
-
-
-
-
-
0
2
3
1
James
Paul
7
Valley
9
11
2636
8
9
2636
10
11
8785
12
2636 >=
(20*100 * 8785)
1
2
0+1=1
3
2
4
5
Juan
Trump
6
7
Baracoda
8
9
2570
10
11
8567
12
2570 >=
(20*100 * 8567)
26
27
28
29
1+1+2
3
30
31
Robert
Singh
32
33
Alpine
34
35
2354
36
37
6725
38
2354 >=
(20*100 * 6725)
39
40
41
42
43
44
2+1=3
4
Michele
Robberts
45
46
Wellington
47
48
1084
49
50
7224
51
1084 >=
(20*100 * 7224)
52
53
3+0=3
54
55
56
57
5
Salma
Peropi
58
59
Alpine
60
61
2018
62
63
6725
64
2018 >=
(20*100 * 6725)
65
66
3+1=4
TEST USE TABLE
C name
district
vr
vc
count Output
1 James Paul
Valley
2636 8785 1
Refund Due for James Paul
2 Juan Trump
Baracoda
2570 8567 2
Refund Due for Juan Trump
3 Robert Singh
Alpine
2354 6725 3
Refund Due for Robert Singh
4 Michele Robberts
Wellington
1084 7224 3
No Refund Due for Michele Robberts
5 Salma Peropi
Alpine
2018 6725 4
Refund Due for Salma Peropi
PROGRAM IMPLEMENTATION
1.(a)Create a software that calculates candidate refunds automatically. It should
evaluate which applicants are qualified for a refund and how much the refund
should be. The software should also output the overall number of refunds and the
number of candidates that received a refund.
1.(b)Program Language ( Pascal )
Program Refunds {Program Implemtation SBA to determine candidate refund and
amount to receive refund};
var
c, count, vr, vc: integer;
name, district: string;
BEGIN
count := 0;
for c := 1 to 5 do
begin
writeln('Enter candidate names');
readln(name);
writeln('Enter district name');
readln(district);
writeln('Enter votes received');
readln(vr);
writeln('Votes cast in district');
readln(vc);
if vr >= (20/100 * vc) then
begin
writeln('Refund Due for ', name);
count := count + 1;
end
else
begin
writeln('No Refund Due for ', name);
end;
end;
writeln('Number of people who received a refund: ', count);
END.
Download