0% found this document useful (0 votes)
31 views

Computer Science IA

Uploaded by

Diondra King
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Computer Science IA

Uploaded by

Diondra King
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

CARIBBEAN ADVANCED PROFICIENCY EXAMINATION

(CAPE)

COMPUTER SCIENCE UNIT 1

INTERNAL ASSESSMENT

Title of Project: Electronic Voting System

Names and Candidate Numbers:

Shanice Alexander

Kiana Cousins

Acacia King

Andrena Williams

Centre Number: 100109

School: St. Hilda’s Diocesan High School

Territory: Jamaica

Year of Examination: 2024

Teacher: Miss Hutton


Electronic Voting System

ACKNOWLEDGEMENT

1|Page
Electronic Voting System

TABLE OF CONTENTS

Acknowledgement ..................................................................................................................... 1

Section 1: ................................................................................................................................... 3

Problem Statement ................................................................................................................. 4

Problem Definition................................................................................................................. 4

Functional Requirements ....................................................................................................... 5

Non-Functional requirements ................................................................................................ 5

Narrative ................................................................................................................................ 6

Section 2: ................................................................................................................................... 7

Psuedocode ............................................................................................................................ 8

Section 3: ................................................................................................................................. 10

Code ..................................................................................................................................... 11

Section 4: ................................................................................................................................. 15

Section 5: ................................................................................................................................. 16

2|Page
Electronic Voting System

SECTION 1:

IDENTIFICATION OF SPECIFICATION

3|Page
Electronic Voting System

PROBLEM STATEMENT
All elections for the position of student council at Progressive High School were conducted

on paper during the academic year 2023-2024. Election paper use can be time-consuming and

laborious, and paper can easily be misplaced.

PROBLEM DEFINITION
Every election held during the school year, for student council, has used conventional paper

ballots since the founding of our institution in 1932. Paper-based elections have been around

for a long time, and this has led to several serious problems. These inclhude inefficiency, the

possibility of misplaced or improperly handled votes, lengthy time requirements, significant

physical space utilization, and a high demand for physical resources like paper.

We suggest creating a website and a software program to handle these issues and simplify our

school's election procedure. This program seeks to lessen the environmental impact of paper

use while improving the election system's accessibility, efficiency, and openness.

4|Page
Electronic Voting System

FUNCTIONAL REQUIREMENTS
➢ Allow candidates to input their personal information.

➢ Display the positions available.

➢ Allow candidates to select their position of interest and to submit a manifesto.

➢ Allow users to cast their votes for a desired candidate.

➢ Display the progress of the current election.

NON-FUNCTIONAL REQUIREMENTS
➢ Maintain data organization.

5|Page
Electronic Voting System

NARRATIVE
The code includes global variables for storing information on candidates, such as their ages,

forms, biographies, and names, as well as an array for tracking votes and a two-dimensional

array for voter identification. The program's primary functions are to register as a candidate,

vote for a candidate, access administrative features, and quit the application.

The menu function is in charge of presenting the user with a list of options, such as

registering as a candidate, voting, contacting administration, or exiting the program. The

'num' variable stores the user's selection. The 'candidate' function facilitates the registration of

aspiring candidates by gathering details such as: name, age, form, and reasons for the

application. Notably, there can only be five candidates in the program at a time.

Users can cast their votes, view the list of candidates, be asked for their ID numbers, and

have their vote counted by the 'voter' function. The application checks the voter's

identification to avoid duplicate votes. To gain access to administrative functions, the 'admin'

function looks for an entered password. The application shows the most recent vote totals and

candidate details after successful authentication.

The main function runs the entire program. It greets users and starts a while loop that shows

the menu 50 times or until an exit command is received. It calls the necessary functions

following the user's selection. Some of the program's restrictions include a set limit of five

candidates, an administration password that is assigned, and a set number of iterations before

the program ends. For a more appealing user experience, sleep statements are also used,

which adds delays.

6|Page
Electronic Voting System

SECTION 2:

DESIGN

7|Page
Electronic Voting System

PSUEDOCODE

// Declare global variables Return


num: integer Display maximum candidates reached
ages: array of integers message
bios: array of strings
v: array of integers // Function for voters
IDlist: 2D array of strings voter ():
Declare option and IDnum variables
// Declare global variables Prompt user to enter their ID number
num: integer and store in IDnum
ages: array of integers Iterate over IDlist:
forms: array of integers If IDnum already exists in IDlist:
bios: array of strings Display already voted message
names: array of strings Set check variable to 1
v: array of integers Break
IDlist: 2D array of strings If check is still 0:
Display list of candidates
// Function to display the main menu Prompt user to enter the name of the
menu (): candidate they want to vote for
Display main menu options Iterate over candidates' array:
Read user input and store in num If the entered name matches a
candidate's name:
// Function for aspiring candidates Increment the corresponding
candidate (): vote count
Iterate over candidates' array: Display success message
If a candidate slot is available: Add IDnum to IDlist
Prompt candidate to enter their Return
name, age, form, and bio Display invalid name message
Store the entered information in the
respective arrays // Function for administrators
Display success message admin ():

8|Page
Electronic Voting System

Declare paswrd variable and set While count is less than 50:
password Call menu () function
Prompt user to enter password and store If num is 1:
in paswrd Call candidate () function
If paswrd matches the password: Else if num is 2:
Display summary of results: If there are still available candidate
Iterate over candidates' array: slots:
If a candidate exists: Call voter () function
Display candidate's Else:
information and vote count Display voting closed message
Else: Else if num is 3:
Display incorrect password message Call admin () function
Else if num is 4:
// Main function Return 0
main (): Increment count
Declare count variable and set to 0 Return 0
Display welcome message

9|Page
Electronic Voting System

SECTION 3:

CODING OF THE PROGRAM

10 | P a g e
Electronic Voting System

CODE
#include<stdio.h> int candidate () {//function to display for
#include<string.h> aspiring candidates.
#include<unistd.h> sleep (1);
#define max 1000 for (int i = 0; i < 5; i++) {
#define max2 50 if(names[i][0] == '\0') {
#define max3 1300 printf("\n+++++++++++++++++++++++++
+++++++++++++++++++++++++++++++
//global variabales ++++++++++\n");
int num; printf ("Thank you for deciding to be a part
int ages [5]; of your school body.\n");
int forms [5]; printf ("Please enter your name: ");
char bios [5] [max]; getchar ();
char names [5] [max2]; fgets (names[i], max2, stdin);
int v [5] = {0}; printf ("Enter your age: ");
char IDlist[max3][6]; scanf ("%d", &ages[i]);
printf ("And finally, your form: ");
int menu () { //function to display at the scanf ("%d", &forms[i]);
starting of the program printf ("Why do you want to be Student
printf("\n**************************** council president? ");
***********************************\ getchar ();
n"); fgets(bios[i], max, stdin);
printf ("!!!!!!!!!!!! MAIN MENU sleep (1);
!!!!!!!!!!!!!!!!"); printf ("\nYou have been successfully
printf ("\nPlease enter the number that recorded as a candidate.\n");
corresponds with your choice:"); return 0;
printf ("\n1. Register as a Candidate.\n2. }
Vote for a candidate.\n3. Administration.\n4. }
Exit Program\n"); sleep (1);
scanf ("%d", &num); printf ("\nThe maximum number of
return 0; candidates have been recorded. Thank you
} for your interest.\n");
return 0;
11 | P a g e
Electronic Voting System

} }
}

int voter () { printf ("\nPlease enter the name of the


char option [max2]; candidate you would like to vote for.\n");
char IDnum [7]; getchar ();
int check = 0; fgets (option, max2, stdin);
sleep (1); for (int i = 0; i < 5; ++i) {
printf("\n========================= if (strcmp (option, names[i]) == 0) {
=============================== v[i]++;
==========\n"); sleep (1);
printf ("Please enter your ID number: "); printf ("\nYour vote for %s has been
scanf ("%s", IDnum); recorded.\nThank you for participating.\n",
names[i]);
for (int i = 0; i < max3; i++) { for (int i = 0; i < max3; i++) {
if (IDlist[i][0]!= '\0' && strncmp if (IDlist[i][0] == '\0') {
(IDlist[i], IDnum, 6) == 0) { strncpy (IDlist[i], IDnum,6);
sleep (1); break;
printf ("You have already voted. If this is a }
mistake, please contact an }
administrator.\n"); return 0;
check = 1; }
break; }
} sleep (1);
} printf ("\nThe name you have entered is
if (check == 0){ invalid. Please enter the name exactly as
sleep (1); shown above.\n");
printf ("The current candidates for the }
student council position are as follows:\n"); return 0;
for (int i = 0; i < 5; ++i) { }
if (names[i][0] != '\0') {
printf ("\n~~~~~~~~~~~\n%s%d int admin () {//function to display summary
years old\nForm %d\n%s", names[i], of information.
ages[i], forms[i], bios[i]); sleep (1);
12 | P a g e
Electronic Voting System

printf("\n############################ printf ("Welcome to Progressive High


################################### School's Student Council Election
####\n"); System.\n");
char paswrd [8]; while (count < 50){
const char * password = "PassworD"; menu ();
printf ("Please enter the password: "); if (num == 1) {
scanf ("%s", &paswrd); candidate ();
} else if (num == 2) {
if (strcmp (paswrd, password) == 0) { if (names [0][0] == '\0' || names [1][0] ==
sleep (1); '\0' || names [2][0] == '\0' || names [3][0] ==
printf ("\nHere are the results thus far:\n"); '\0' || names [4][0] == '\0') {
for (int i = 0; i < 5; ++i) { sleep (0.7);
if(names[i][0] != '\0’) { printf ("\nVoting is closed until the
printf ("\n%s%d years old\nForm %d\n%s= maximum candidates are obtained.\n");
%d votes\n", names[i], ages[i], forms[i], } else {
bios[i], v[i]); voter ();
} }
} } else if (num == 3) {
} else { admin ();
sleep (1); } else if (num == 4) {
printf ("\nIncorrect password.\n"); return 0;
} }
return 0; ++ count;
} }
return 0;
int main () { }
int count = 0;

13 | P a g e
Electronic Voting System

14 | P a g e
Electronic Voting System

SECTION 4:

TESTING AND PRESENTATION

15 | P a g e
Electronic Voting System

SECTION 5:

DOCUMENTATION

16 | P a g e

You might also like