Sei sulla pagina 1di 107

ELECTION VOTING SYSTEM

SUBMITTED BY: NAME- KUMAR NEERAV REGISTRATION NO. - 581270

DATE OF SUBMISSION:

UNDER THE GUIDANCE OF: Mrs. Arpana Chaturvedi

Submitted in partial fulfillment of the requirements for qualifying DOEACC A Level. Name & Address of the accredited institute:
JAGANNATH INSTITUTE OF MANAGEMENT & SCIENCES MATHURA ROAD NEW DELHI

Table of Contents: S. No.


1 2

Topics
Acknowledgement Certificate Objective of the Project Scope Of the Project Theoretical Background Definition of Problem System Analysis and Design Feasibility Study Project Life Cycle Design System Planning (PERT CHART) Methodology Hardware & Software Requirement Cost & Benefit Analysis Life Cycle of The Project System Testing & Implementation Screenshots Documentation Conclusion Future Scope of the Project List of Table List of Figures Data Dictionary REFRENCES

Page No.
3 4 5 6 7 10 12

3 4 5

6 7 8 9 10 11 12 13 14 15 16

24 27 31 33 35 44 48 53 101 103 105 105 106 107

--2--

ACKNOWLEDGEMENT

I would like to thanks to all my guides who really acted as pillars to help my way throughout this project that has led to successful and satisfactory completion of this study of this project. Firstly I would like to thanks my project incharge Mrs. Arpana Chaturvedi under whose able guidance and motivation this work has been performed.

The inspiration of the faculty members of the Computer Science Department of JIMS MATHURA ROAD enabled me to make a thorough study of this subject. Last but not the least, no acknowledgement will be complete without mentioning my family and friends. They have also supported me throughout the development projects.

NAME: KUMAR NEERAV REG. NO.: 581270

--3--

CERTIFICATE

This is to certify that the Project entitled, ELECTION VOTING SYSTEM is a bona-fide work done by Mr. KUMAR NEERAV (DOEACC Registration No: 581270) in partial fulfillment of A Level examination and has been carried out under my direct supervision and guidance. This report or a similar report on the topic has not been submitted for any other examination and does not forma part of any other course undergone by the candidate.

Signature of Guide / Supervisor Name: Place: Arpana chaturvedi New Delhi

Designation: Sr. lecturer Date: 28-08-2010 Address:


Jagannath Institute of Management Sciences.

--4--

Objective of the Project


Today IT field is emerging day by day. The process is going very fast everyday. Everything is being done on a single click. In ancient days there were a register or a diary to maintain a record. But today every work is done by the computer and with a great security. And this process is always developing day by day.

In this fast growing world of IT I just want to help out the industry with making of a small software naming ELECTION VOTING SYSTEM. This software will keep up the updated data of the all the voters and candidates in the voting system, etc. This will keep up the data till then you want to keep it and always allow you to update the changes.

So, thats all from the introduction of the software. Hope you like my software.

--5--

SCOPE OF THE PROJECT

Today, IT industry is known as word of magic. No doubt it brings a universal change in society. The existing manual system is very tedious; therefore this system is used to get the existing system more efficient and fast. The proposed system aims to develop a system that helps to manage all drawbacks of the existing system. The system has a user friendly environment where the end user can perform all the activity. Even if the user has little knowledge of computers he/she can easily operate. The proposed system has the following objectives to be achieved.

User Friendly Environment. Less Space. Fast Retrieval. Easy to Operate. Accuracy. Cost Reduction.

--6--

THEORETICAL BACKGROUND

--7--

The main objective of the ELECTION VOTING SYSTEM is to perform all the functions or operations accurately. It overcomes all the problems that we have in our existing system. Our existing system is as follows: I. Redundancy of data: - when the data values are stored repeatedly in multiple copies in the database it is known as redundancy of data. Multiple copies of the same data serve no useful purpose. On contrary it wastes expansive storage space besides introducing other types of problem. Due to this, our database becomes lengthy and difficult to maintain. If there is duplication of data, then there is a possibility of inconsistency of data. Due to the above problem, it is very difficult to handle the database. For example, if a passenger generates a query and there is duplication of data, it is impossible to processing the passengers query. II. a. Update Problem:- The updation problem is further categorized into three category:Insertion Problem: - In manual record keeping system the user may enter the irrelevant values or data, manual system not force any constraints. Therefore Insertion problem implies writing of wrong, irrelevant data into the table. This leads to inaccuracy or inconsistency of data into the tables. Thus the new computerized system checks that the right data is entered into the table or not, or gives the error when the user input the wrong data. b. Updation Problem: - In the manual record keeping system there is a problem arise when the user update the data, due to duplicacy of the record the user faces many difficulties because if the user want to update one record the user is forced update all the duplicate records of that, but practically it is not possible to change all the duplicate records this leads to in accuracy in the result.

Deletion Problem: - In the existing system, there may be a possibility of duplication of records. If the user wants to cancel his/her record, then he/she want to delete all the duplicate records. Practically it is not possible to delete all existing duplicate record.

--8--

Apart of duplication problem and updation problem, there is another problem that is, our existing system is very slow. The process of inserting, updating or deleting of records is limited to speed of operator. And maintaining registers or papers is very difficult there is need of extra storage space and person who maintain the registers of records. There are more chances of loses of records during handling of records

--9--

DEFINATION OF PROBLEM

- - 10 - -

The current system is not organized. It is a system based on more of manual work. The main idea behind this system is to save ELECTION VOTING SYSTEM records with their request related to the voters and the candidates. The speed of the system depends on the human speed. The conventional system in the ELECTION VOTING SYSTEM is manual where all the work is done manually by entering the records in the various files and folders. It is quite cumbersome to proceed through the manual system because, allotments of various aspects of addition, modification, searching, deletion and also the maintenance of it take ample time. Maintaining these files requires a lot of space as well. Since it is totally depending on human, efficiency is low. There is less security as all the information is basically kept as hard copy in a register. The computer back up is also in the file system.

- - 11 - -

SYSTEM ANALYSIS & DESIGN

- - 12 - -

Feasibility Study
Feasibility is the measure of how beneficial or practical the development of an information system will be to an organization. Feasibility analysis is the process of measuring Feasibility.

Feasibility analysis is a cross life cycle activity, which has to be continuously performed throughout the system development. By using the creeping commitment approach, feasibility is measured at different times in the system development. This evaluation ensures that the project is beneficial and practical to an organization.

Feasibility Test:There are four types of Feasibility Test: Operational Feasibility Technical Feasibility Schedule Feasibility

Economic Feasibility

Operational Feasibility:This application is very easy to operate as it is made user friendly. Main consideration is users easy access to all the functionality of the application. The PIECE formula is used as the basis for analyzing the urgency of the problem. PIECE stands for:

P- Performance - Throughput

- - 13 - -

- Response Time

I- Information - Input - Output - Stored Data

E- Economics - Cost of Processing Order is high - Too many employee involve in one operation

C- Control - Too little control or security - Effort required for job is excessive

E- Efficiency - System not co-ordinate with another system - How end user and manager feel about the system

Technical Feasibility:Measure of practically of a specific technical solution and availability of technical resources. Technology is infeasible and not practical if the organization cant afford the technology, so make sure that the chosen technology is known and easy to solve. In this there is no need of any special hardware.

Schedule Feasibility:It is measured that how reasonable the project timetable is.

- - 14 - -

Economic Feasibility:Measure of the cost-effectiveness of a project solution.

- Cost Benefit Analysis


As soon as the specific requirements and solutions have been identified, the analysts can way the cost and benefits of each alternative.

Project Life Cycle:The basic objective of software engineering is to: develop methods and procedures for software development that can scale up for large systems and that can be used to consistently produce high quality software at low cost and with a small cycle time. That is, the key objectives are consistency, low cost, high quality, small cycle time, and scalability.

The basic approach that software engineering takes is to separate the development process from the software. The premise is that the development process controls the quality, scalability, consistency, and productivity. Hence to satisfy the objectives, one must focus on the development process. Design of proper development process and their control is the primary goal of the software engineering. It is this focus on the process that distinguishes it from most other computing disciplines. Most other computing disciplines focus on some type of the product-algorithms, operating systems, databases etc. while software engineering focuses on the process for producing products.

To better manage the development process and to achieve consistency, it is essential that the software development be done in phases.

Different Phases of the Development Process: - - 15 - -

1) Requirement Analysis:

Requirement analysis is done in order to understand the problem the software system is to solve. The problem could be automating an existing manual process, developing a new automated system, or a combination of the two. The emphasis in requirements analysis is on identifying what is needed from the system, not how the system will achieve its goals. There are at least two parties involved in the software development-a client and a developer. The developer has to develop the system to satisfy the clients needs. The developer does not understand the clients problem domain, and the client does not understand the issues involved in the software systems. This causes a communication gap, which has to be adequately bridged during requirements analysis.

2) Software Design:

The purpose of the design phase is to plan a solution of the problem specified by the requirements documents. This phase is the first step in moving from the problem domain to the solution domain. Starting with what is needed; design takes us toward how to satisfy the needs. The design of a system is perhaps the most critical factor affecting the quality of the software. It has a major impact on the later phases, particularly testing and maintenance. The design activity is divided into two phases: System Design and Detailed Design. In system design the focus is on identifying the modules, whereas during detailed design the focus is on designing the logic for each of the modules 3) Coding:

The goal of the coding phase is to translate the design of the system into code in a given programming language. Hence during coding, the focus should be on developing

programs that are easy to read and understand, and not simply on developing programs that are easy to write.

- - 16 - -

4) Testing:

Testing is the major quality control measure used during software development. Its basic function is to detect errors in the software. Testing not only uncover errors introduced during coding, but also errors introduced during the previous phases. Thus, the goal of the testing is to uncover requirement, design and coding errors in the programs. Therefore, different levels of testing are used. Testing is an extremely critical and time consuming activity. It requires proper planning of the overall testing process. The output of the testing phase is the test report and the error report. Test report contains the set of test cases and the result of executing the code with these test cases. The error report describes the errors encountered and the action taken to remove the errors.

One such life cycle model is the Waterfall Model. In the traditional life cycle model, called the waterfall model, each phase has well-defined starting and ending points, with clearl y identifiable deliverables to the next phase. In practice, it is rarel y so simple.

A waterfall life c ycle model comprises the following phases: Requirements anal ysis and specification Design and specification Coding and module testing Integration and s ystem testing Delivery and maintenance

- - 17 - -

The Waterfall Model

Analysis

DESIGN

CODING

TESTING

IMPLEMENTA TION

FIG 5.1

- - 18 - -

This application used the above described SDLC model for the successful completion and implementation along with testin g of the project. The Development Lifecycle of a project includes the following 3 sta ges: Project Initiation Project Execution Project Completion In Proj ect Initiation stage, a team prepares the project plan and finalizes the outcome of each stage. Here, the team also prepares a comprehensive list of tasks, and the project mana ger assigns responsibilities to the team members, depending on their skills and abilities.

In the Project Execut ion stage, the team develops the product. Here, in the case of our project, we developed the ELECTION VOTIN G SYSTEM. This stage is further classified as: Requirements Analysis High Level Design Low Level Design Construction

During this phase, we anal yzed the requirements to be fulfilled by the job search utilit y & identified the probable approach for meeting these requirements. To identify the requirements we studied the various job search utilities at the various websites. and finall y we identified the following requirements:

- - 19 - -

Enable a registered user to logon, after his/her login details are validated. Enable the user to can access the finalities provided as authorized b y administrator. Allow the users to quickl y search for details.

In the Project Completion stage, we completed the documentation of our project and givin g final touches to our project.

DESIGN:In the system design process, the primary objective is to identify user requirements and to build a system that satisfies these requirements. Design OS system is largely the logical design. The logical design can be sketched on a paper or on a computer terminal. The design, also include the physical design elements, describes the data to be inputted, the process involved in the manipulation of data and the output.

(a) The analyst should specify the file structures, storage devices etc. (b) The database is also designed in this phase. (c) Hardware cost, capability, speed, error rates, and other performance characteristics are specified. (d) Changes to be made in the organization structure of the firm are outlined. (e) Input, output, files, forms and procedures are planned. (f) Finally, standards for testing, documentation and system control are formulated.

E-R Diagram:Entity-Relationship (E-R) analysis involves capturing and analyzing of maximum possible details on data record for building an information system for an orgn. Entity

- - 20 - -

relationship (E-R) modeling is concerned with the structure of data rather than with the business rules. Some amount of business rules may also be implied in the E-R model. Structure of data involves details on entities, attributes & relationships. Business rules define such characteristics as the domain value of attributes, unique characteristics of entities, relationships among different entities and validating operations to be performed during data entry. E-R analysis involves the following: Determining what types of people, places, things and materials interacts with the business and about which objects the data must be maintained. These objects form the entities. Determining different characteristics (attributes) of each entity. This involves identifying only those characteristics which are of interest to the orgn. And for which the system is being built. Determining what unique feature such as the primary key can be used to identify an entity in an entity set. Determining the associations (relationships) among identified objects. Entity Relationship Modeling:The entity relationship model for data uses three features to describe data. These are the followings:Entities An entity is a person, place, thing or event of interest to the organization and about which data are captured, stored or processed. For eg. an Employee is an entity. Attributes Various types of data items that describe an entity are known as attributes. For eg. Name, address, DOB etc are attributes of the entity employee. Relationship An association of several entities in a entity relation model is called relationship.

- - 21 - -

E-R Diagram Symbols:Name Rectangle Symbol Meaning Represented entity set Represented Attributes

Oval

Diamond

Represents relationships among entity sets

Line

Links attributes to entity sets and entity sets to relationships

- - 22 - -

E-R Diagram:-

Vote Name Name Code

Show

Age Voter Gender Uses

Edit Voting System

Effects

Name Code Fig 5.2 Determi -nes Name Candidates

Summary Party Sign

Party Name

- - 23 - -

SYSTEM PLANNING

- - 24 - -

PERT CHART: - It is stands for Project Evaluation and review Technique Pert chart is a graphical network model that depicts a projects tasks and the relationship between those tasks. A PERT chart presents a graphic illustration of a project as a network diagram consisting of numbered nodes (either circles or rectangles) representing events, or milestones in the project linked by labeled vectors (directional lines) representing tasks in the project.

The direction of the arrows on the lines indicates the sequence of tasks.

Arrow is used to represents task.

Circle represents the beginning or completion of task.

The PERT chart process includes following steps: Identifies the specific activities and milestone. Determine the proper sequence of the activities. Construct a network diagram. Estimate the time required for each activity. Determine the critical path. Update the PERT chart as the process progresses.

- - 25 - -

PERT CHART Problem Definition 1 Feasibility study 2 5 System analyze & Design 5 Flow chart 3 4 6 10 Coding Data Dictionary DF 5 5 4

7 34 Testing 8

Implementation 9

- - 26 - -

METHODOLOGY

- - 27 - -

C++ is a general-purpose, high-level programming language with low-level facilities. It is a statically typed free-form multi-paradigm language supporting procedural programming, data abstraction, object-oriented programming, generic programming and Runtime Type Identification (RTTI). Since the 1990s, C++ has been one of the most popular commercial programming languages. Bjarne Stroustrup developed C++ (originally named "C with Classes") in 1983 at Bell Labs as an enhancement to the C programming language. Enhancements started with the addition of classes, followed by, among other features, virtual functions, operator overloading, multiple inheritance, templates, and exception handling. The C++ programming language standard was ratified in 1998 as ISO/IEC 14882:1998, the current version of which is the 2003 version, ISO/IEC 14882:2003. In past years the standards for C++ have been in a state of evolution. This meant that each compiler vendor handled certain details differently. However, in November 1997, the ANSI/ISO C++ standards committee approved the final draft of what is now known as Standard C++. (ANSI stands for American National Standards Institute, and ISO stands for International Standards Institute). Standard C++ adds many new features to the language, such as the Standard Template Library (STL).

The most popular development environments for C++ are manufactured by Microsoft and Borland and run on the various flavors of Microsoft Windows.

OOP involves concepts that are new to programmers of traditional languages such as Pascal, Basic, and C. These ideas, such as classes, inheritance, and polymorphism, lie at the heart of object-oriented programming. History Stroustrup began work on C with Classes in 1979. The idea of creating a new language originated from Stroustrup's experience in programming for his Ph.D. thesis. Stroustrup found that Simula had features that were very helpful for large

- - 28 - -

software development, but the language was too slow for practical use, while BCPL was fast but too low-level and unsuitable for large software development. When Stroustrup started working in Bell Labs, he had the problem of analyzing the UNIX kernel with respect to distributed computing. Remembering his Ph.D. experience, Stroustrup set out to enhance the C language with Simula-like features. C was chosen because it is general-purpose, fast, and portable. Besides C and Simula, some other languages which inspired him were ALGOL 68, Ada, CLU and ML. At first, the class, derived class,

strong type checking, inlining, and default argument features were added to C via Cfront. The first commercial release occurred in October 1985. In 1983, the name of the language was changed from C with Classes to C++. New features were added including virtual functions, function name and operator overloading, references, constants, user-controlled free-store memory control, improved type checking, and a new single-line comment style with two forward slashes (//). In 1985, the first edition of The C++ Programming Language was released, providing an important reference to the language, as there was not yet an official standard. In 1989, Release 2.0 of C++ was released. New features included multiple inheritance, abstract classes, static member functions, const member functions, and protected members. In 1990, The Annotated C++ Reference Manual was published. This work became the basis for the future standard. Late addition of features included templates, exceptions, namespaces, new casts, and a Boolean type.

As the C++ language evolved, a standard library also evolved with it. The first addition to the C++ standard library was the stream I/O library which provided facilities to replace the traditional C functions such as printf and scanf. Later, among the most significant additions to the standard library, was the Standard Template Library.

After years of work, a joint ANSI-ISO committee standardized C++ in 1998 (ISO/IEC 14882:1998). For some years after the official release of

- - 29 - -

the standard in 1998, the committee processed defect reports, and published a corrected version of the C++ standard in 2003. In 2005, a technical report, called the "Library Technical Report 1" (often known as TR1 for short) was released. While not an official part of the standard, it gives a number of extensions to the standard library which are expected to be included in the next version of C++. Support for TR1 is growing in almost all currently maintained C++ compilers.

While the C++ language is royalty-free, the standard document itself is not freely available Features introduced in C++ Compared to the C language, C++ introduced extra features, including declarations as statement, function-like casts, new/ delete, reference type, inline functions, default arguments, function overloading, namespaces, classes Features are: Identity Classification Encapsulation Data abstraction Polymorphism Inheritance

Including all class-related features such as i member function, virtual function, abstract classes, and constructors, operator overloading, templates, the :: operator, exception handling, and runtime type identification.

- - 30 - -

HARDWARE & SOFTWARE REQUIREMENT

- - 31 - -

Hardware requirements: Intel Pentium III processor Minimum 128 MB RAM Recommended 256 MB RAM Minimum hard disk 20GB

Software requirements: Windows operating system C++ complier compatible with the Windows OS

Networking requirements: Internet connection The estimated cost of these entire requirements is around 10000 to 12000 There are sufficient cost benefits because computerized system has better efficiency than manual system and it also reduces the hiring cost of peons or clerks for maintaining the files. In the new system the accessing is much faster than the old manual system so it also beneficial in terms of time.

- - 32 - -

COST AND BENEFIT ANALYSIS

- - 33 - -

COST-BENEFITS ANALYSIS Cost Categories Equipment cost Operating cost It includes various items of computing equipment associated with the work. It includes the expense to run the system. Operating cost depends on the amount of time taken for a process i.e., it includes the cost associated with the day to day operation of the system.

Personnel cost

It includes the salaries and wages of analyst, programmers, operators, consultants etc. Salary may be on hourly basis or the entire salary for the duration of the project.

Material cost Conversion cost

It includes cost of stationary, paper, ribbons, floppies, CDs etc. It includes that of designing new forms and procedures, expenditure to prepare the project for using the new system.

Benefit Categories Performance The criteria emphasize whether the new system has resulted in a marked improvement in the accuracy in access to information. Does the new system provide easier and secure access to the authorized user If the new system is efficient with minimum error, reduction of staff is a benefit that should be measured and included in cost benefit analysis

Minimizing cost

- - 34 - -

LIFE CYCLE OF THE PROJECT

- - 35 - -

Data Flow Diagram (DFD):Data Flow Diagrams provide a logical model of the system and show the flow of data and the flow of the logic involved. Data Flow Diagram have the following characteristics: They show the passage of data through the system They focus on the processes that transform incoming data flows (input) into outgoing data flows (outputs). The processes that perform this transformation normally create as well as use data. External entities send and receive data flows from the system. Data Flow Diagram is also known as Bubble Chart. Data Flow Diagram supports a top-down approach for analysis.

Symbols used in DFD:DFD consist of symbols joined together by a line. There may be a single DFD for entire system or it may be exploded into various levels, namely level 1, level 2, level 3 etc. The top-level diagram is often called a Context Diagram. Context Diagram contains a single process and it shows an overall review of the system under development. Four Symbols are used in drawing dataflow diagram. These are: External Entities (Source or sink) Data Flow Processes Data Store External Entities:An external entity is a source or a destination of data. External entities are represented by rectangles. These may be people, program, organization or other entities that enteract with system.

- - 36 - -

Data Flow:Data flow diagram shows how data travels from one point to another point in the diagram. The flow is shown as an arrowed line with the arrowhead showing the direction of flow. The data flow is given a simple and meaningful descriptive name such as order details or customer payment etc. The data flow may move from an external entity to a process, from one process to another process and from and process to an external entity.

An External Entity

Entity Name

Data Flow

Process No Process No

Processes

Process Name

or
Process Name

Data Store

Data Store name

- - 37 - -

CONTEXT LEVEL DFD

VOTER

CANDIDATE

VOTING SYSTEM
Fig 5.3

- - 38 - -

0 LEVEL DFD

VOTER

CANDIDATE

Update Details

Enter Details

VOTER SYSTEM

Maintain Details

Check Details

Fig 5.4

- - 39 - -

1st LEVEL DFD


Voter Req uest

1.0 Prepare Voter Detail

Update Voter Register

2.0

Verify Candidate
Prepare Candidate System

Candidate Register

Fig- 5.5
3.0 Voting Information Detail

Update

Current Record Table

- - 40 - -

2ND LEVEL DFD

Request

1.1

Voter

Add Voter Name

Voter Register

1.1

Modify Voter Name

Updat ed Data
1.1

Delete Voter Name Fig 5.6

- - 41 - -

Request

2.1

Candidate

Add Candidate Name

Candidate Register

2.2

Modify Candidate Name

Updat ed Data

2.3

Delete Candidate Name

- - 42 - -

Request

3.1

Voter

Add Voter Name

Current Record Register

3.2

Add Candidate Name

Updat ed Data
3.3

Voting System

- - 43 - -

SYSTEM TESTING AND IMPLEMENTATION

- - 44 - -

Testing
The most crucial stage of software development, testing validates the application. During testing we will be concerned about the inputs and their expected outputs. We emphasize on the testing where we will input the data and compare the output with the expected results. At this stage we are not concerned about the process; we are only looking for correct outputs. Various software testing techniques exists which take different approaches to test and validate a software.

Tests done on the designed software was to verify the following properties of the software:

Correctness(satisfaction of the specifications)

Reliability(how well it meets the requirements)

Portability (running in different environments)

Usability (ease with which user can use the software)

Maintainability (modifications after initial release), etc.

Some of them, which we used to test the software, are:

Unit Testing
Unit testing focuses verification effort on the smallest unit of software design The software component or module. Using component level design description as a guide, important control paths are tested to uncover errors within the boundary of the - - 45 - -

module. Tests of data flow across a module interface were carried out for each module of the software. Errors in certain modules were detected and later rectified, thus correcting the dataflow path.

Integration Testing
Once all the modules have been unit tested, they are interfaced together and passed through integration testing using top down integration approach.

Black Box Testing


This approach enables the software engineer to derive sets of input conditions that will fully exercise all functional requirements for a program. This approach is applied during the later stages of testing and attention is focused on matching the outputs with the expected result.

Debugging
Debugging is removing the undesirable errors or bugs from the program. We implemented debugging using the C++ compiler compatible with the Windows system in which the application was developed.

During testing the program to tested is executed with the set of test cases and have the output of the program for the test cases is evaluated to determine if the program is performing as expected. Due to its approach dynamic if the program is performing as expected. Due to its approach dynamic testing can only presence of errors in the program, the exact nature of errors is not usually decided by testing. Testing forms is the process to determine errors in the program.

Once a program are tested individually then the system as a whole needs to be tested. During testing the system is used experimentally to ensure that the software does not fail i.e. it will run according to its specification. The programs executed to check for

- - 46 - -

any syntax and logical errors. The errors are corrected and test is made to determine whether the program is doing what supposed to do. The cautions kept in mind while choosing the tests are: 1. 2. 3. The testing should be based on sound and systematic techniques. Testing should help locate errors, not just detect their presence. Testing should be repeatable, i.e., repeating the same experiment, supplying the same input data to the same piece of code, produces the same results.

IMPLEMENTATION
System implementation is made up of many activities. The six major activities we are concerned with in this chapter are coding, testing, installation, documentation, training and support. The purpose of these steps is to convert the physical system specification into working and reliable software and hardware, document the work that has been done, and provide help for current and future users and caretakers of the system. These steps are often done by other project team members besides analysts, although analysts may do some programming. In any case, analyst is responsible for ensuring that all the various activities are properly planned and executed.

In the implementation phase, user actually starts using the system. This phase therefore involves training the users for using the system and also providing theem driendly documentation to refer to.

In system implementation, user training is crucial for minimizing resistance to change and giving the mew system a chance to prove its worth. Training aid such as user manuals, a data dictionary, job performance aids that communicate information about the new system and help screens, provide the user with a good start on the new system.

- - 47 - -

SCREENSHOTS

- - 48 - -

Description:-

Menu:-

- - 49 - -

1: Voting report

2: See Menu

- - 50 - -

3: Edit

- - 51 - -

- - 52 - -

DOCUMENTATION

- - 53 - -

WHAT IS DOCUMENTATION?

Documentation is a description of the system used to communicate, instruct and record information for historical, operational or reference purposes. Documents are very important because they represent the formal information flow of the present system. Documentation establishes and declares the performance criteria of system and provides and explanation of how the system can be used.

USES OF DOCUMENTATION

Documentation is used in many ways for different purpose. These are as follows:

Documents facilitate communication about an application between the technical development personnel and the on technical users. Documents are necessary during abnormal maintenance, i.e. when a new programmer has to maintain old software system after the original programmer of analyst has left the organization.

It is also very helpful to train the users. Good documentation will provide a self-instructional approach that will allow employees to learn at their own place.

Documents are also very helpful for trouble shooting when the applicationsystem breaks down. Documents help corporate management to understand the system sufficiently to make decisions and to appreciate its financial and resource implications.\ Documentation can provide controls not only internal to the firm, but also external to the business application such as audit trails. Documentation also helps in the evaluation process.

- - 54 - -

//********************************************************** // PROJECT ELECTION-VOTING SOFTWARE //********************************************************** #include<iostream.h> #include<fstream.h> #include<process.h> #include<string.h> #include<stdlib.h> #include<stdio.h> #include<ctype.h> #include<conio.h> #include<dos.h>

char description() { delay(2000); cout<<"\t\t ELECTION VOTING SOFTWARE \n\n"; delay(500); cout<<"\t DESCRIPTION : IN THIS PROJECT , A PREDETERMINED SET OF \n\n\n"; delay(500); cout<<"\t VOTERS WILL BE ABLE TO CAST THE VOTE .VOTERS WILL HAVE \n\n\n"; delay(500); cout<<"\t TO PROVE THEIR IDENTITY BY GIVING THEIR IDENTIFICATION \n\n\n"; delay(500); cout<<"\t NO. A AUTHENTICATED USER WILL BE ABLE TO CAST THE VOTE.\n\n\n"; delay(500); cout<<"\t A USER WHO HAS CASTED THE VOTE CANNOT CAST AGAIN.AFTER \n\n\n"; delay(500); cout<<"\t VOTING HAS FINISHED RESUTS WILL BE DECLAIR. A SETUP \n\n\n"; delay(500); cout<<"\t OPTION BEFORE ELECTION STARTS , WILL ALLOW VOTER TO BE \n\n\n"; delay(500); cout<<"\t CREATED AND CANDIDATE CHOOSEN. \n\n\n"; delay(1500); cout<<"\n\n\n\t\t\tPLEASE PRESS ENTER TO CONTINUE & Esc. TO EXIT\t"; char ch; for(;;) {

- - 55 - -

ch=getch(); if(ch==13) break; else if(ch==27) exit(-1); else cout<<"\n\n\t\t\t\a ! WRONG KEY ENTERED !"; delay(300); cout<<"\n\n\n\n\t\t\t PRESS ENTER "; } return 0; } int string_is_number(char* s) { int size = strlen(s); for(int i = 0; i < size; i++) if (!(s[i] >= '0' && s[i] <= '9')) return 0; return 1; } class candidate_record { public: int candidate_namecode ; char candidate_name[50] ; char partyname[50], partysign[50] ; char summary[1]; char revenue[100]; char age[100]; char area[50]; }; class voter_record { public: int voter_namecode ; char voter_name[50] ; char age[10], gender[10] ; }; class voter_status { public:

- - 56 - -

int voter_namecode; int voting_status; }; class candidate_status { public: int candidate_namecode; int numVotes; };

class vote { public : void add_candidate_name(void) ; void delete_candidate_name(void) ; void modify_candidate_name(void) ; void list_of_candidate_names(void) ; void voting(void) ; void add_voter_name(void) ; void delete_voter_name(void) ; void modify_voter_name(void) ; void list_of_voters_names(void) ; private : int last_candidate_code(int &num_candidates) ; void delete_candidate_record(int) ; void modify_candidate_record(int) ; void display_candidate_record(int) ; int name_candidate_found(int) ; int candidate_recordno(int, candidate_record&) ; void candidate_sort(void) ;

int last_voter_code(int &num_voters) ; void delete_voter_record(int) ; void modify_voter_record(int) ; void display_voter_record(int) ; int name_voter_found(int) ; int voter_recordno(int, voter_record &vr) ; void voter_sort(void) ; voter_status* init_voter_status(int &num); candidate_status* init_candidate_status(int &num); };

- - 57 - -

class menu { public : void main_menu(void) ; private : void edit_menu(void) ; vote v; };

void menu :: main_menu(void) { clrscr() ; char ch ; while (1) { clrscr(); gotoxy(27,4) ; cout<<" E L E C T I O N "; gotoxy(27,6); cout <<" V O T I N G S O F T W A R E " ; gotoxy(31,8) ; cout <<"~~~~~~~~~~~~~~~~~~~~~~~" ; gotoxy(32,9) ; cout <<"1: VOTE " ; gotoxy(32,11) ; cout <<"2: SEE MENU " ; gotoxy(32,13) ; cout <<"3: EDIT " ; gotoxy(32,17) ; cout <<"0: QUIT " ; gotoxy(32,20) ; cout <<"Enter Choice : " ; ch = getche() ; if (ch == 27) return ; else if (ch == '1') { vote v ; v.voting() ; } else

- - 58 - -

if (ch == '2') { vote v ; v.list_of_candidate_names() ; gotoxy(1,20) ; cout <<"Press any key to see the voters details" ; getche() ; v.list_of_voters_names(); } else if (ch == '3') edit_menu() ; else if (ch == '0') break ; } }

void menu :: edit_menu(void) { clrscr(); char ch,choice; cout<<" \EDIT \MENU \n\n"; cout<<" 1: \* EDIT CANDIDATE RECORD \*\n"; cout<<" 2: \* EDIT VOTER RECORD \*\n"; cout<<" 0: \* EXIT \*\n"; cout<<" \ENTER \CHOICE: "; choice = getche(); if (choice == '1') { while(1) { gotoxy(28,10) ; cout <<" * EDIT CANDIDATE RECORD *" ; gotoxy(28,12) ; cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ; gotoxy(28,14) ; cout <<"1: * \ADD \CANDIDATE \NAME * " ; gotoxy(28,16) ; cout <<"2: * \MODIFY \CANDIDATE \NAME *" ;

- - 59 - -

gotoxy(28,18) ; cout <<"3: * \DELETE \CANDIDATE \NAME *" ; gotoxy(28,20) ; cout <<"0: * \EXIT *" ; gotoxy(28,22) ; cout <<" ENTER CHOICE: " ; ch = getche() ; if (ch == '1') { vote v ; v.add_candidate_name() ; break ; } else if (ch == '2') { vote v ; v.modify_candidate_name() ; break ; } else if (ch == '3') { vote v ; v.delete_candidate_name() ; break ; } else if (ch == '0') break ; } } if(choice=='2') { while (1) { gotoxy(28,10) ; cout <<" * EDIT VOTER RECORD *" ; gotoxy(28,12) ; cout <<" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ; gotoxy(28,14) ; cout <<"1: * \ADD \VOTER \NAME * " ; gotoxy(28,16) ; cout <<"2: * \MODIFY \VOTER \NAME * " ; gotoxy(28,18) ; cout <<"3: * \DELETE \VOTER \NAME * " ; gotoxy(28,20) ; cout <<"0: * EXIT " ;

- - 60 - -

gotoxy(28,22) ; cout <<"Enter Choice: " ; ch = getche() ; if (ch == '1') { vote v ; v.add_voter_name() ; break ; } else if (ch == '2') { vote v ; v.modify_voter_name() ; break ; } else if (ch == '3') { vote v ; v.delete_voter_name() ; break ; } else if (ch == '0') break ; } } }

int vote :: last_voter_code(int &num_voters) { voter_record vr; fstream file ; num_voters = 0; file.open("VOTER.DAT", ios::in|ios::binary) ; file.seekg(0,ios::beg) ; int t=0 ; while (file.read((char *)&vr,sizeof(voter_record))) { t = vr.voter_namecode ; num_voters++; } file.close() ; return t ; }

- - 61 - -

void vote :: list_of_voters_names(void) { clrscr() ; voter_record vr; fstream file ; file.open("VOTER.DAT", ios::in|ios::binary) ; file.seekg(0) ; int row = 6 , found = 0 , pageno = 1 ; gotoxy(30,2) ; cout <<"LIST OF NAMES OF VOTERS" ; gotoxy(29,3) ; cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ; gotoxy(3,4) ; cout <<"NAME CODE NAME AGE GENDER" ; gotoxy(2,5) ; cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ; while (file.read((char *)&vr, sizeof(voter_record))) { delay(20) ; found = 1 ; gotoxy(5,row) ; cout <<vr.voter_namecode ; gotoxy(14,row) ; cout <<vr.voter_name ; gotoxy(37,row) ; cout <<vr.age; gotoxy(51,row) ; cout <<vr.gender; ; if ( row == 22 ) { row = 5 ; gotoxy(66,1) ; cout <<"Page no. : " <<pageno ; gotoxy(66,2) ; cout <<"===============" ; pageno++ ; gotoxy(1,25) ; cout <<"Press any key to continue..." ; getche() ; clrscr() ; gotoxy(3,4) ; cout << "NAME CODE NAME AGE GENDER " ; gotoxy(2,5) ; cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ;

- - 62 - -

} else row++ ; } if ( !found ) { gotoxy(5,10) ; cout <<"\7Records not found " ; } gotoxy(66,1) ; cout <<"Page no. : " <<pageno ; gotoxy(66,2) ; cout <<"===============" ; gotoxy(1,20) ; cout <<"Press any key to continue..." ; getche() ; file.close () ; } void vote :: add_voter_name(void) { voter_record vr; int vcode, valid ; char ch; int num_voters; vcode = last_voter_code(num_voters) ; vcode++ ; do { clrscr() ; gotoxy(71,2) ; cout <<"<0>=Exit" ; gotoxy(23,3) ; cout <<" ADD NAME TO THE VOTER LIST" ; gotoxy(23,4) ; cout <<" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ; gotoxy(5,6) ; cout <<"Name Code : " <<vcode ; gotoxy(5,8) ; cout <<"Name: " ; gotoxy(5,10) ; cout <<"Age: " ; gotoxy(5,12) ; cout <<"Gender: " ; do {

- - 63 - -

valid = 1 ; gotoxy(1,8) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER NAME OF THE VOTER TO ADD IN THE LIST" ; gotoxy(5,8) ; cout <<" Name : " ; gets(vr.voter_name) ; strupr(vr.voter_name) ; if (vr.voter_name[0] == '0') return ; if ((strlen(vr.voter_name) < 1) || (strlen(vr.voter_name) > 50)) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = A...Z" ; getch() ; } } while (!valid) ; do { valid = 1 ; gotoxy(1,10) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER AGE OF VOTER TO ADD IN THE LIST" ; gotoxy(5,10) ; cout <<"Age : " ; gets(vr.age) ; strupr(vr.age); if (vr.age[0] == '0') return ; if ((strlen(vr.age) < 1) || (strlen(vr.age) > 3 ) || (!string_is_number(vr.age))) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = 18...100" ; getch() ; } if (atoi(vr.age) < 18) { valid = 0; gotoxy(3,24); cout <<"\7 Voter's age is less than 18";

- - 64 - -

getch(); } } while (!valid) ; do { valid = 1 ; gotoxy(1,12) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER GENDER OF VOTER TO ADD IN THE MENU" ; gotoxy(5,12) ; cout <<"GENDER : " ; gets(vr.gender) ; strupr(vr.gender); if (vr.gender[0] == '0') return ; if ((strlen(vr.gender) < 1) ||(strlen(vr.gender) > 1) || (strcmp(vr.gender,"M") && strcmp(vr.gender,"F"))) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = M/F" ; getch() ; } } while (!valid) ; do { gotoxy(1,15) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(5,15) ; cout <<"Do you want to save this record (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'N' && ch != 'Y') ; if (ch == 'Y') { vr.voter_namecode = vcode ; fstream file ; file.open("VOTER.DAT", ios::out | ios::app |ios::binary) ; file.write((char *)&vr, sizeof(voter_record)) ; file.close() ;

- - 65 - -

vcode++ ; } do { gotoxy(1,17) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(5,17) ; cout <<"Do you want to add more records (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'N' && ch != 'Y') ; } while (ch == 'Y') ; }

void vote :: display_voter_record(int vcode) { voter_record vr; fstream file ; file.open("VOTER.DAT", ios::in|ios::binary) ; file.seekg(0,ios::beg) ; while (file.read((char *)&vr, sizeof(voter_record))) { if (vr.voter_namecode == vcode) { gotoxy(5,3) ; cout <<"Name Code : "<<vr.voter_namecode ; gotoxy(5,4) ; cout <<"Name : "<<vr.voter_name ; gotoxy(5,5) ; cout <<"Age : "<<vr.age ; gotoxy(5,6) ; cout <<"Gender : "<<vr.gender ; break ; } } file.close() ; }

int vote :: name_voter_found(int tcode) { voter_record vr;

- - 66 - -

fstream file ; file.open("VOTER.DAT", ios::in|ios::binary) ; file.seekg(0,ios::beg) ; int found=0 ; while (file.read((char *)&vr, sizeof(voter_record))) { if (vr.voter_namecode == tcode) { found++ ; break ; } } file.close() ; return found ; }

int vote :: voter_recordno(int tcode, voter_record &vr) { voter_record temp; fstream file ; file.open("VOTER.DAT", ios::in|ios::binary) ; file.seekg(0,ios::beg) ; int found=0 ; while (file.read((char *)&temp, sizeof(voter_record))) { found++ ; if (temp.voter_namecode == tcode) { vr = temp; break ; } } file.close() ; return found ; }

void vote :: delete_voter_record(int tcode) { voter_record vr; fstream file ; file.open("VOTER.DAT", ios::in|ios::binary) ; fstream temp ; temp.open("temp.dat", ios::out|ios::binary) ;

- - 67 - -

file.seekg(0,ios::beg) ; while ( !file.eof() ) { file.read((char *)&vr, sizeof(voter_record)) ; if ( file.eof() ) break ; if ( vr.voter_namecode != tcode ) temp.write((char *)&vr, sizeof(voter_record)) ; } file.close() ; temp.close() ; file.open("VOTER.DAT", ios::out|ios::binary) ; temp.open("temp.dat", ios::in|ios::binary) ; temp.seekg(0,ios::beg) ; while ( !temp.eof() ) { temp.read((char *)&vr, sizeof(voter_record)) ; if ( temp.eof() ) break ; file.write((char *)&vr, sizeof(voter_record)) ; } file.close() ; temp.close() ; }

void vote :: delete_voter_name(void) { clrscr() ; char t_code[5], ch ; int tcode ; gotoxy(3,25) ; cout <<"Press <ENTER> to see the list" ; gotoxy(5,3) ; cout <<"Enter Name Code of the item to be deleted : " ; gets(t_code) ; tcode = atoi(t_code) ; if (tcode == 0) { list_of_voters_names() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"Press <ENTER> to Exit" ; gotoxy(5,24) ; cout <<"Enter Name Code of the item to be deleted : " ;

- - 68 - -

gets(t_code) ; tcode = atoi(t_code) ; if (tcode == 0) return ; } clrscr() ; if (!name_voter_found(tcode)) { gotoxy(5,5) ; cout <<"\7Record not found" ; getch() ; return ; } display_voter_record(tcode) ; do { gotoxy(1,8) ; clreol() ; gotoxy(5,8) ; cout <<"Do you want to delete this record (y/n) : " ; ch = getche() ; ch = toupper(ch) ; } while (ch != 'N' && ch != 'Y') ; if (ch == 'N') return ; delete_voter_record(tcode) ; gotoxy(5,15) ; cout <<"\7Record Deleted" ; getch() ; }

void vote :: modify_voter_record(int tcode) { voter_record vr; int recno ; recno = voter_recordno(tcode,vr) ; if (recno == 0) return; int valid, t_code ; char ch,t_namecode[5] ; gotoxy(71,2) ; cout <<"<0>=Exit" ; gotoxy(5,12) ; cout <<"Name Code : " ; gotoxy(5,14) ;

- - 69 - -

cout <<" Name : " ; gotoxy(5,16) ; cout <<" Age : " ; gotoxy(5,18) ; cout <<"Gender: " ; do { gotoxy(20,12) ; clreol() ; cout <<"Change (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'N' && ch != 'Y') ; valid = 0 ; while (ch == 'Y' && !valid) { valid = 1 ; gotoxy(1,12) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER NAME CODE TO ADD IN THE MENU" ; gotoxy(5,12) ; cout <<"Name Code : " ; gets(t_namecode) ; vr.voter_namecode = atoi(t_namecode) ; if (vr.voter_namecode == 0) return ; if (name_voter_found(vr.voter_namecode) && vr.voter_namecode != tcode) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 CODE ALREADY GIVEN" ; getch() ; } } do { gotoxy(20,14) ; clreol() ; cout <<"Change (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'N' && ch != 'Y') ;

- - 70 - -

valid = 0 ; while (ch == 'Y' && !valid) { valid = 1 ; gotoxy(1,14) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER NAME TO ADD IN THE MENU" ; gotoxy(5,14) ; cout <<" Name : " ; gets(vr.voter_name) ; strupr(vr.voter_name) ; if (vr.voter_name[0] == '0') return ; if ((strlen(vr.voter_name) < 1) || (strlen(vr.voter_name) > 50)) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = 1..50" ; getch() ; } } do { gotoxy(20,16) ; clreol() ; cout <<"Change (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'N' && ch != 'Y') ; valid = 0 ; while (ch == 'Y' && !valid) { valid = 1 ; gotoxy(1,16) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER AGE OF VOTER TO ADD IN THE MENU" ; gotoxy(5,16) ; cout <<"Age : " ; gets(vr.age) ; strupr(vr.age); if (vr.age[0] == '0')

- - 71 - -

return ; if ((strlen(vr.age) < 1) || (strlen(vr.age) > 10) || !string_is_number(vr.age)) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = 1..10" ; getch() ; } } do { gotoxy(20,18) ; clreol() ; cout <<"Change (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'N' && ch != 'Y') ; valid = 0 ; while (ch == 'Y' && !valid) { valid = 1 ; gotoxy(1,18) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER GENDER OF VOTER TO ADD IN THE MENU" ; gotoxy(5,18) ; cout <<"Gender : " ; gets(vr.gender) ; strupr(vr.gender); if (vr.gender[0] == '0') return ; if ((strlen(vr.gender) < 1) || (strlen(vr.gender) > 10)) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = " <<vr.gender <<"..10" ; getch() ; } } do { gotoxy(1,21) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ;

- - 72 - -

gotoxy(5,21) ; cout <<"Do you want to save this record (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'N' && ch != 'Y') ; if (ch == 'N') return ; getch() ; fstream file ; file.open("VOTER.DAT", ios::out | ios::ate|ios::binary) ; int location ; location = (recno-1) * sizeof(vr) ; cout << " Location is " << location; file.seekp(location) ; file.write((char *) &vr, sizeof(voter_record)) ; file.close() ; voter_sort() ; clrscr() ; gotoxy(5,15) ; cout <<"\7Record Modified" ; getch() ; }

void vote :: modify_voter_name(void) { clrscr() ; char t_code[5], ch ; int tcode ; gotoxy(3,25) ; cout <<"Press <ENTER> to see the list" ; gotoxy(5,3) ; cout <<"Enter Name Code of the item to be Modify : " ; gets(t_code) ; tcode = atoi(t_code) ; if (tcode == 0) { list_of_voters_names() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"Press <ENTER> to Exit" ; gotoxy(5,24) ; cout <<"Enter Name Code of the item to be modify : " ;

- - 73 - -

gets(t_code) ; tcode = atoi(t_code) ; if (tcode == 0) return ; } clrscr() ; if (!name_voter_found(tcode)) { gotoxy(5,5) ; cout <<"\7Record not found" ; getch() ; return ; } display_voter_record(tcode) ; do { gotoxy(5,8) ; cout <<"Do you want to Modify this record (y/n) : " ; ch = getche() ; ch = toupper(ch) ; } while (ch != 'N' && ch != 'Y') ; if (ch == 'N') return ; modify_voter_record(tcode) ; }

void vote :: voter_sort(void) { int i=0,j ; voter_record *arr, temp ; fstream file ; file.open("VOTER.DAT", ios::in|ios::binary) ;

while (file.read((char *) &temp, sizeof(voter_record))) i++ ; file.clear();

arr = (voter_record*) new voter_record[i]; int size ; size = i ;

- - 74 - -

file.seekg(0,ios::beg) ; for( i = 0; i < size; i++) file.read((char*)&(arr[i]),sizeof(voter_record)); file.close() ; for (i=1; i<size; i++) { for (j=0; j<size-i; j++) { if (arr[j].voter_namecode > arr[j+1].voter_namecode) { temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } } file.open("VOTER.DAT", ios::out|ios::binary) ; for (i=0; i<size; i++) file.write((char *) &arr[i], sizeof(voter_record)); delete[] arr; file.close() ; }

void main(void) { clrscr() ; char des; description(); // exit(); clrscr(); char p; clrscr(); menu m ; m.main_menu() ; }

- - 75 - -

void vote :: candidate_sort(void) { int i=0,j ; candidate_record *arr, temp ; fstream file ; file.open("CANDIDATE.DAT", ios::in|ios::binary) ; while (file.read((char *) &temp, sizeof(candidate_record))) i++ ; file.clear(); arr = (candidate_record*) new candidate_record[i]; int size ; size = i ; file.seekg(0,ios::beg) ; for( i = 0; i < size; i++) file.read((char*)&arr[i],sizeof(candidate_record)); file.close() ; for (i=1; i<size; i++) { for (j=0; j<size-i; j++) { if (arr[j].candidate_namecode > arr[j+1].candidate_namecode) { temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } } file.open("CANDIDATE.DAT", ios::out|ios::binary) ; for (i=0; i<size; i++) file.write((char *) &arr[i], sizeof(candidate_record)); delete[] arr;

- - 76 - -

file.close() ; }

void vote :: modify_candidate_name(void) { clrscr() ; char t_code[5], ch ; int tcode ; gotoxy(3,25) ; cout <<"Press <ENTER> to see the list" ; gotoxy(5,3) ; cout <<"Enter Name Code of the item to be Modify : " ; gets(t_code) ; tcode = atoi(t_code) ; if (tcode == 0) { list_of_candidate_names() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"Press <ENTER> to Exit" ; gotoxy(5,24) ; cout <<"Enter Name Code of the item to be modify : " ; gets(t_code) ; tcode = atoi(t_code) ; if (tcode == 0) return ; } clrscr() ; if (!name_candidate_found(tcode)) { gotoxy(5,5) ; cout <<"\7Record not found" ; getch() ; return ; } display_candidate_record(tcode) ; do { gotoxy(5,8) ; cout <<"Do you want to Modify this record (y/n) : " ; ch = getche() ; ch = toupper(ch) ; } while (ch != 'N' && ch != 'Y') ;

- - 77 - -

if (ch == 'N') return ; modify_candidate_record(tcode) ; }

void vote :: modify_candidate_record(int tcode) { candidate_record cr; int recno ; int revenue; recno = candidate_recordno(tcode,cr) ; int valid, t_code ; char ch,t_namecode[5] ; gotoxy(71,2) ; cout <<"<0>=Exit" ; gotoxy(5,12) ; cout <<"Name Code : " ; gotoxy(5,14) ; cout <<" Name : " ; gotoxy(5,16) ; cout <<" Party Name : " ; gotoxy(5,18) ; cout <<"Party Sign: " ; gotoxy(5,20) ; cout <<"Summary : " ; do { gotoxy(20,12) ; clreol() ; cout <<"Change (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'N' && ch != 'Y') ; valid = 0 ; while (ch == 'Y' && !valid) { valid = 1 ; gotoxy(1,12) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER NAME CODE TO ADD IN THE MENU" ; gotoxy(5,12) ;

- - 78 - -

cout <<"Name Code : " ; gets(t_namecode) ; cr.candidate_namecode = atoi(t_namecode) ; if (cr.candidate_namecode == 0) return ; if (name_candidate_found(cr.candidate_namecode) && cr.candidate_namecode != tcode) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 CODE ALREADY GIVEN" ; getch() ; } } do { gotoxy(20,14) ; clreol() ; cout <<"Change (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'N' && ch != 'Y') ; valid = 0 ; while (ch == 'Y' && !valid) { valid = 1 ; gotoxy(1,14) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER NAME TO ADD IN THE MENU" ; gotoxy(5,14) ; cout <<" Name : " ; gets(cr.candidate_name) ; strupr(cr.candidate_name) ; if (cr.candidate_name[0] == '0') return ; if ((strlen(cr.candidate_name) < 1) || (strlen(cr.candidate_name) > 50)) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = 1..50" ; getch() ; } } do

- - 79 - -

{ gotoxy(20,16) ; clreol() ; cout <<"Change (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'N' && ch != 'Y') ; valid = 0 ; while (ch == 'Y' && !valid) { valid = 1 ; gotoxy(1,16) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER PARTY NAME TO ADD IN THE MENU" ; gotoxy(5,16) ; cout <<"Party Name : " ; gets(cr.partyname) ; strupr(cr.partyname); if (cr.partyname[0] == '0') return ; if ((strlen(cr.partyname) < 1) || (strlen(cr.partyname) > 50)) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = 1..50" ; getch() ; } } do { gotoxy(20,18) ; clreol() ; cout <<"Change (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'N' && ch != 'Y') ; valid = 0 ; while (ch == 'Y' && !valid) { valid = 1 ; gotoxy(1,18) ; clreol() ; gotoxy(1,24) ; clreol() ;

- - 80 - -

gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER PARTY SIGN TO ADD IN THE MENU" ; gotoxy(5,18) ; cout <<"Party Sign : " ; gets(cr.partysign) ; strupr(cr.partysign);

if (cr.partysign[0] == '0') return ; if ((strlen(cr.partysign) < 1) || (strlen(cr.partysign) > 50)) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = " <<cr.partysign <<"..50" ; getch() ; } } do { gotoxy(20,20) ; clreol() ; cout <<"Change (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'N' && ch != 'Y') ; valid = 0 ; while (ch == 'Y' && !valid) { valid = 1 ; gotoxy(1,20) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER THE SUMMARY OF THE CANDIDATE" ; gotoxy(5,20) ; cout <<"Summary declared: " ; gets(cr.summary) ; strupr(cr.summary);

if (cr.summary[0] == '0') return ; if ((strlen(cr.summary) < 1) || (strlen(cr.summary) > 50))

- - 81 - -

{ valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = " <<cr.summary <<"..50" ; getch() ; } } do { gotoxy(1,21) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(5,21) ; cout <<"Do you want to save this record (y/n) : " ; ch = getche() ; ch = toupper(ch) ; if (ch == '0') return ; } while (ch != 'N' && ch != 'Y') ; if (ch == 'N') return ; getch() ; fstream file ; file.open("CANDIDATE.DAT", ios::out | ios::ate|ios::binary) ; int location ; location = (recno-1) * sizeof(cr) ; file.seekp(location) ; file.write((char *) &cr, sizeof(candidate_record)) ; file.close() ; candidate_sort() ; clrscr() ; gotoxy(5,15) ; cout <<"\7Record Modified" ; getch() ; }

int vote :: name_candidate_found(int tcode) { candidate_record cr; fstream file ; file.open("CANDIDATE.DAT", ios::in|ios::binary) ; file.seekg(0,ios::beg) ; int found=0 ; while (file.read((char *)&cr, sizeof(candidate_record))) {

- - 82 - -

if (cr.candidate_namecode == tcode) { found++ ; break ; } } file.close() ; return found ; }

void vote :: display_candidate_record(int tcode) { candidate_record cr; fstream file ; file.open("CANDIDATE.DAT", ios::in|ios::binary) ; file.seekg(0,ios::beg) ; while (file.read((char *)&cr, sizeof(candidate_record))) { if (cr.candidate_namecode == tcode) { gotoxy(5,3) ; cout <<"Name Code : "<<cr.candidate_namecode ; gotoxy(5,4) ; cout <<"Name : "<<cr.candidate_name ; gotoxy(5,5) ; cout <<"Party Name : "<<cr.partyname ; gotoxy(5,6) ; cout <<"Party Sign : "<<cr.partysign ; gotoxy(5,7) ; cout <<"Revenue : "<<cr.revenue ; gotoxy(5,8) ; cout <<"Age : "<<cr.age ; gotoxy(5,9) ; cout <<"Area : "<<cr.area ; break ; } } file.close() ; }

void vote :: add_candidate_name(void) { candidate_record cr; int tcode, valid ;

- - 83 - -

char ch; int num_candidates; tcode = last_candidate_code(num_candidates) ; tcode++ ; do { clrscr() ; gotoxy(71,2) ; cout <<"<0>=Exit" ; gotoxy(27,3) ; cout <<" ADD NAME TO THE CANDIDATE LIST" ; gotoxy(26,4) ; cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ; gotoxy(5,6) ; cout <<"Name Code : " <<tcode ; gotoxy(5,8) ; cout <<"Name : " ; gotoxy(5,10) ; cout <<"Party Name : " ; gotoxy(5,12) ; cout <<"Party Sign : " ; gotoxy(5,14) ; cout <<"Summary : " ; do { valid = 1 ; gotoxy(1,8) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"ENTER NAME TO ADD IN THE CANDIDATE LIST" ; gotoxy(5,8) ; cout <<"Name : " ; gets(cr.candidate_name) ; strupr(cr.candidate_name) ; if (cr.candidate_name[0] == '0') return ; if ((strlen(cr.candidate_name) < 1) || (strlen(cr.candidate_name) > 50)) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = A.....Z" ; getch() ; } }while (!valid) ; do

- - 84 - -

{ valid = 1 ; gotoxy(1,10) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(5,25) ; cout <<"ENTER PARTY NAME TO ADD IN THE LIST" ; gotoxy(5,10) ; cout <<"Party Name : " ; gets(cr.partyname) ; strupr(cr.partyname); if (cr.partyname[0] == '0') return ; if ((strlen(cr.partyname) < 1) || (strlen(cr.partyname) > 50)) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = A.....Z" ; getch() ; } } while (!valid) ; do { valid = 1 ; gotoxy(1,12) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(5,25) ; cout <<"ENTER PARTY SIGN TO ADD IN THE MENU" ; gotoxy(5,12) ; cout <<"Party Sign : " ; gets(cr.partysign) ; strupr(cr.partysign); if (cr.partysign[0] == '0') return ; if ((strlen(cr.partysign) < 1) ||(strlen(cr.partysign) > 50)) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = A.....Z" ; getch() ; } } while (!valid) ; do {

- - 85 - -

valid = 1; gotoxy(1,14) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(5,25) ; cout <<"ENTER SUMMARY OF THE CANDIDATE" ; gotoxy(5,14) ; cout <<"SUMMARY AS FOLLOWS " ; getch(); // gets(cr.summary) ; strupr(cr.summary); if (cr.summary[0] == '0') return ; if ((strlen(cr.summary) < 1) ||(strlen(cr.summary) > 50)) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = A.....Z" ; getch() ; } } while (!valid) ; do { valid = 1; gotoxy(1,16) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(5,25) ; cout <<"ENTER REVENUE OF THE CANDIDATE" ; gotoxy(5,16) ; cout <<"Revenue : " ; gets(cr.revenue) ; strupr(cr.revenue); if (cr.revenue[0] == '0') return ; if ((strlen(cr.revenue) < 1) ||(strlen(cr.revenue) > 50)) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = A.....Z" ; getch() ; } } while (!valid) ; do

- - 86 - -

{ valid = 1; gotoxy(1,18) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(5,25) ; cout <<"ENTER AGE OF THE CANDIDATE" ; gotoxy(5,18) ; cout <<"Age : " ; gets(cr.age) ; strupr(cr.age); if (cr.age[0] == '0') return ; if ((strlen(cr.age) < 1) ||(strlen(cr.age) > 50)) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = A.....Z" ; getch() ; } } while (!valid) ; do { valid = 1; gotoxy(1,20) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(5,25) ; cout <<"ENTER AREA OF THE CANDIDATE" ; gotoxy(5,20) ; cout <<"Area : " ; gets(cr.area) ; strupr(cr.area); if (cr.area[0] == '0') return ; if ((strlen(cr.area) < 1) ||(strlen(cr.area) > 50)) { valid = 0 ; gotoxy(3,24) ; cout <<"\7 Range = A.....Z" ; getch() ; } } while (!valid) ; do

- - 87 - -

{ gotoxy(1,15) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(5,28) ; cout <<"Do you want to save this record (y/n) : " ; ch = getche() ; ch = toupper(ch) ; } while (ch != 'N' && ch != 'Y') ; if (ch == 'Y') { cr.candidate_namecode = tcode ; fstream file ; file.open("CANDIDATE.DAT", ios::out | ios::app | ios::binary) ; file.write((char *)&cr, sizeof(candidate_record)) ; file.close() ; tcode++ ; } do { gotoxy(1,17) ; clreol() ; gotoxy(1,24) ; clreol() ; gotoxy(1,25) ; clreol() ; gotoxy(5,30) ; cout <<"Do you want to add more records (y/n) : " ; ch = getche() ; ch = toupper(ch) ; } while (ch != 'N' && ch != 'Y') ; } while (ch == 'Y') ; }

void vote :: list_of_candidate_names(void) { clrscr() ; candidate_record cr; fstream file ; file.open("CANDIDATE.DAT", ios::in|ios::binary) ; file.seekg(0) ; int row = 6 , found = 0 , pageno = 1 ; gotoxy(30,2) ; cout <<"LIST OF NAMES OF CANDIDATES" ; gotoxy(29,3) ; cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ;

- - 88 - -

gotoxy(3,4) ; cout <<"NAME CODE NAME PARTY NAME PARTY SIGN REVENUE AGE AREA"; gotoxy(2,5) ; cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~" ; while (file.read((char *)&cr, sizeof(candidate_record))) { delay(20) ; found = 1 ; gotoxy(5,row) ; cout <<cr.candidate_namecode ; gotoxy(14,row) ; cout <<cr.candidate_name ; gotoxy(31,row) ; cout <<cr.partyname ; gotoxy(45,row) ; cout <<cr.partysign ; gotoxy(58,row) ; cout <<cr.revenue ; gotoxy(69,row) ; cout <<cr.age ; gotoxy(75,row) ; cout <<cr.area ; if ( row == 22 ) { row = 5 ; gotoxy(66,1) ; cout <<"Page no. : " <<pageno ; gotoxy(66,2) ; cout <<"===============" ; pageno++ ; gotoxy(1,25) ; cout <<"Press any key to continue..." ; getche() ; clrscr() ; gotoxy(3,4) ; cout << "NAME CODE NAME PARTY NAME PARTY SIGN REVENUE AGE AREA" ; gotoxy(2,5) ; cout <<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~" ; } else

- - 89 - -

row++ ; } if ( !found ) { gotoxy(5,10) ; cout <<"\7Records not found " ; } gotoxy(66,1) ; cout <<"Page no. : " <<pageno ; gotoxy(66,2) ; cout <<"===============" ; gotoxy(1,20) ; cout <<"Press any key to continue..." ; getche() ; file.close () ; }

int vote :: last_candidate_code(int &num_candidates) { candidate_record cr; fstream file ; num_candidates = 0; file.open("CANDIDATE.DAT", ios::in|ios::binary) ; file.seekg(0,ios::beg) ; int t=0 ; while (file.read((char *) &cr, sizeof(candidate_record))) { t = cr.candidate_namecode ; num_candidates++; } file.close() ; return t ; }

int vote :: candidate_recordno(int tcode,candidate_record &cr) { candidate_record temp; fstream file ; file.open("CANDIDATE.DAT", ios::in|ios::binary) ; file.seekg(0,ios::beg) ; int found=0 ;

- - 90 - -

while (file.read((char *) &temp, sizeof(candidate_record))) { found++ ; if (temp.candidate_namecode == tcode) { cr = temp; break ; } } file.close() ; return found ; }

void vote :: delete_candidate_record(int tcode) { candidate_record cr; fstream file ; file.open("CANDIDATE.DAT", ios::in|ios::binary) ; fstream temp ; temp.open("temp.dat", ios::out|ios::binary) ; file.seekg(0,ios::beg) ; while ( !file.eof() ) { file.read((char *)&cr, sizeof(candidate_record)) ; if ( file.eof() ) break ; if ( cr.candidate_namecode != tcode ) temp.write((char *)&cr, sizeof(candidate_record)) ; } file.close() ; temp.close() ; file.open("CANDIDATE.DAT", ios::out|ios::binary) ; temp.open("temp.dat", ios::in|ios::binary) ; temp.seekg(0,ios::beg) ; while ( !temp.eof() ) { temp.read((char *)&cr, sizeof(candidate_record)) ; if ( temp.eof() ) break ; file.write((char *) &cr, sizeof(candidate_record)) ; } file.close() ; temp.close() ; }

- - 91 - -

void vote :: delete_candidate_name(void) { clrscr() ; char t_code[5], ch ; int tcode ; gotoxy(3,25) ; cout <<"Press <ENTER> to see the list" ; gotoxy(5,3) ; cout <<"Enter Name Code of the item to be deleted : " ; gets(t_code) ; tcode = atoi(t_code) ; if (tcode == 0) { list_of_candidate_names() ; gotoxy(1,25) ; clreol() ; gotoxy(3,25) ; cout <<"Press 0 to EXIT" ; gotoxy(5,24) ; cout <<"Enter Name Code of the item to be deleted : " ; gets(t_code) ; tcode = atoi(t_code) ; if (tcode == 0) return ; } clrscr() ; if (!name_candidate_found(tcode)) { gotoxy(5,5) ; cout <<"\7Record not found" ; getch() ; return ; } display_candidate_record(tcode) ; do { gotoxy(1,8) ; clreol() ; gotoxy(5,8) ; cout <<"Do you want to delete this record (y/n) : " ; ch = getche() ; ch = toupper(ch) ; } while (ch != 'N' && ch != 'Y') ; if (ch == 'N')

- - 92 - -

return ; delete_candidate_record(tcode) ; gotoxy(5,15) ; cout <<"\7Record Deleted" ; getch() ; } voter_status* vote::init_voter_status(int &num) { voter_status *vs = NULL; num = 0; last_voter_code(num); if (num != 0) { vs = new voter_status[num]; voter_record vr; fstream file ; file.open("VOTER.DAT", ios::in|ios::binary) ; for(int i = 0; i < num; i++) { file.read((char *)&vr, sizeof(voter_record)); vs[i].voter_namecode = vr.voter_namecode; vs[i].voting_status = 0; } file.close(); } return vs; } candidate_status* vote::init_candidate_status(int &num) { candidate_status *cs = NULL;; num = 0; last_candidate_code(num); if (num != 0) { cs = new candidate_status[num]; candidate_record cr; fstream file; file.open("CANDIDATE.DAT",ios::in|ios::binary); for(int i = 0; i < num; i++) { file.read((char *)&cr, sizeof(candidate_record)); cs[i].candidate_namecode = cr.candidate_namecode; cs[i].numVotes = 0; } file.close();

- - 93 - -

} return cs; }

void vote::voting() { clrscr() ; char ch,name[50]; int n ,num_voters = 0, num_candidates = 0; int vtr_rec; voter_status* vs = init_voter_status(num_voters); candidate_status* cs = init_candidate_status(num_candidates); int valid=0; if (num_voters == 0) { gotoxy(3,6); cout << "There are NO VOTERS"; ch = getche(); delete[] vs; delete[] cs; return; } if (num_candidates == 0) { gotoxy(3,6); cout << "There are NO CANDIDATES"; ch = getche(); delete[] vs; delete[] cs; return; } while(1) { clrscr(); gotoxy(30,2); cout <<"VOTING HAS STARTED"; gotoxy(29,3); cout <<"~~~~~~~~~~~~~~~~~~~~~~"; { int i;

- - 94 - -

for(i = 0; i < num_voters; i++) { if (vs[i].voting_status == 0) break; } if (i == num_voters) { gotoxy(3,4); cout<<"All VOTES have been casted"; getche(); break; } } gotoxy(3,24) ; clreol(); cout <<"To End the voting Enter <STOP>.\n"; gotoxy(3,25); clreol(); cout <<"Once voting is stopped it cann't resume. You will have to start a fresh" ; gotoxy(6,3); clreol(); cout <<"Enter the voter code <To view listof voters press <ENTER>- "; gets(name); if (strcmp(name,"STOP") == 0) { //Terminate the Voting; gotoxy(6,5); clreol(); cout <<"Do you want to STOP the voting and start counting votes (y/n) - "; ch = getche(); ch = toupper(ch); while(!(ch == 'Y' || ch == 'N')) { gotoxy(70,5); clreol(); ch = getche(); ch = toupper(ch); } if (ch == 'N') { gotoxy(6,5); clreol(); continue; }

- - 95 - -

else break; } n = string_is_number(name); gotoxy(6,5); clreol(); if (n == 0) { cout << "Incorrect voter code, enter only digits, try again "; getche(); continue; } n = atoi(name); if (n == 0) { list_of_voters_names(); continue; }

for(vtr_rec = 0; vtr_rec < num_voters; vtr_rec++) { if (vs[vtr_rec].voter_namecode == n) { if (vs[vtr_rec].voting_status == 1) { cout << "Voter with voter code "<< n <<" has alread voted"; } getche(); break; } } if ( vtr_rec == num_voters) { cout << "Voter code "<< n << " not found in Voter list"; getche(); continue; } if (vs[vtr_rec].voting_status == 1) { cout << "Voter code "<<n<< " has already voted, can't vote again"; getche(); continue; }

- - 96 - -

while(1) { clrscr(); gotoxy(3,24) ; clreol(); cout<<"To cast invalid vote press <y>"; gotoxy(3,3); cout <<"Voter with voter code " << vs[vtr_rec].voter_namecode<<" is voting"; gotoxy(3,4); cout<<"Enter the candidate code <To view list of candidate press <ENTER>-" ; char can_code[50]; gets(can_code); if (can_code[0] == 'Y' || can_code[0] == 'y') { vs[vtr_rec].voting_status = 1; clrscr(); cout<<"Voter "; gotoxy(3,7); display_voter_record(vs[vtr_rec].voter_namecode); gotoxy(3,8); cout <<"has casted a invalid vote"; getche(); break; }

int can = string_is_number(can_code); gotoxy(3,6); if (can == 0) { cout << "Incorrect candidate code, enter only digits, try again "; getche(); continue; } can = atoi(can_code); if (can == 0) { list_of_candidate_names(); getche();

- - 97 - -

continue; } int can_rec; for(can_rec=0; can_rec<num_candidates; can_rec++) { if (cs[can_rec].candidate_namecode == can) break; } if (can_rec == num_candidates) { cout <<"Candidate code "<<can<<" not found in Candidate List"; getche(); continue; } cs[can_rec].numVotes++; vs[vtr_rec].voting_status = 1; clrscr(); gotoxy(3,6); voter_record vr; voter_recordno(vs[vtr_rec].voter_namecode, vr) ; cout<<"Voter " << vr.voter_name<< " has voterd for Candidate "; candidate_record cr; candidate_recordno(cs[can_rec].candidate_namecode,cr); cout << cr.candidate_name; gotoxy(35,20); cout<<"VOTE CASTED"; getche(); valid=1; break; } }

if (valid) { clrscr(); gotoxy(20,9); cout<<"VOTING RESULTS"; int tie =0; int winner=0; int max = 0;

- - 98 - -

int i; for(i = 0; i < num_candidates; i++) { if (cs[i].numVotes > max) { max = cs[i].numVotes; } else if (cs[i].numVotes == max && max > 0) tie = 1; } gotoxy(20,12); if (tie) cout<<"Voting has resulted in tie, joint winners are"; else cout <<"WINNER is "; gotoxy(20,13); for(i = 0; i < num_candidates; i++) { if (cs[i].numVotes == max) { candidate_record cr; candidate_recordno(cs[i].candidate_namecode,cr); if (winner) cout<<", "; cout << "\n\n\t\t\t"<<cr.candidate_name<<endl; gotoxy(25,25); cout<<"THE SUMMARY FOLLOWS"; delay(500); gotoxy(25,27); delay(500); cout << "PARTY NAME -->"<<cr.partyname<<endl; gotoxy(25,29); delay(500); cout << "PARTY SIGN -->"<<cr.partysign<<endl; gotoxy(25,31); delay(500); cout << "REVENUE -->"<<cr.revenue<<endl; gotoxy(25,33); delay(500); cout << "AGE -->"<<cr.age<<endl; gotoxy(25,35); delay(500); cout << "AREA -->"<<cr.area; winner++; } }

- - 99 - -

} ch = getche(); delete[] vs; delete[] cs; }

- - 100 - -

CONCLUSION

- - 101 - -

This software is a database project with all the basic capabilities a database should have. This application software is about Voting Management System. It records the list of candidates, voters etc. The entered records will be saved and can be shown further. In doing so, an appreciation of project management, communication and consultancy skills should be acquired, along with a thorough understanding of the development of windows based applications using C++. I feel that all of these aims were achieved, some to greater extent than others. I will break down these objectives in the following sections, and discuss what was achieved from them.

- - 102 - -

FUTURE SCOPE OF THE PROJECT

- - 103 - -

Including module to enable the softwares user to keep tracks of number of Voters & Candidates. Including a module that adds number of Voters & Candidates. Including a module to enter the data. A module in which number of voters polling can be viewed Including a module to view the available candidates and voters. Help Exit.

- - 104 - -

List of tables S. No
01 02 03

Table No.
1 2 3

Disc. Of Table
Vote See Menu Edit

List of Figures S. No. 01 02 03 04 05 06 Fig. No. 5.1 5.2 5.3 5.4 5.5 5.6 Disc. of Fig. Waterfall Model E-R Diagram Context Level DFD Zero Level DFD First Level DFD Second Level DFD Page No. 22 28 31 32 33 34

- - 105 - -

Data Dictionary

Attributes ch pass[20] Candidate_namecode[10] Candidate_name[50] partyname[50] partysign[50] summary[1] Revenue[100] Age[100] Area[50] Voter_namecode Voter_name Age[10] Gender[10] Voting_status numvotes

Data type char char int char char char char char Char Char Int Char Char Char Int int

- - 106 - -

REFRENCES

1. E-Balaguruswami- Object Oriented Programming With C++ 2. DOEACC A level 3. Wikipedia 4. www.cforum.com 5. www.yahoogroups.com 6. System Analysis And Design- Jain & Jain

- - 107 - -

Potrebbero piacerti anche