Skip to content

yogeshkumarsaini/Voting-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🗳️ Voting System in Java (OOP-Based)

A console-based Voting System built using Java and Object-Oriented Programming (OOP) principles. This project demonstrates real-world voting logic, including age validation, unique voter identification, duplicate vote prevention, and tie handling. Ideal for beginners, college mini-projects, and practicing Java OOP concepts.

🚀 Features

  • Age Validation: Only voters aged 18 and above can participate.
  • 🆔 Unique Voter ID: Each voter must provide a unique identifier.
  • 🚫 Duplicate Vote Prevention: Ensures no voter can cast multiple votes.
  • 🗳️ Multi-Candidate Voting: Support for voting among multiple candidates.
  • 📊 Vote Counting and Results: Displays final vote tallies and outcomes.
  • ⚖️ Automatic Tie Detection: Handles scenarios where candidates tie for the lead.
  • 🧩 Modular OOP Design: Clean, encapsulated classes for maintainability.

🧠 Concepts Used

  • Object-Oriented Programming (OOP)
  • Classes and Objects
  • Encapsulation
  • Arrays and Collections (e.g., HashSet, ArrayList)
  • Loops and Conditional Statements
  • Scanner for User Input

🏗️ Project Structure

VotingSystem.java   # Main class to run the application
Election.java       # Handles voting logic and validations
Candidate.java      # Model class for candidates
Voter.java          # Model class for voters

▶️ How to Run

  1. Clone the Repository:

    git clone <repository-url>
    cd voting-system-java
  2. Compile the Code:

    javac *.java
  3. Run the Application:

    java VotingSystem

🔒 Key Highlights

  • 🆔 Voter ID Validation: Ensures every voter provides a unique ID; duplicates are rejected automatically.
  • 🚫 Duplicate Vote Prevention: Tracks voted IDs using a HashSet to allow only one vote per voter.
  • ⚖️ Tie Handling: If candidates tie for the highest votes, the result is declared as a tie.

🌱 Future Enhancements

  • Integrate file or database storage for voter and election data.
  • Add an admin panel for candidate management.
  • Develop a GUI version using Swing or JavaFX.
  • Transform into a REST API with Spring Boot.

About

A console-based voting system in Java built with OOP principles, featuring age validation, unique voter IDs, duplicate vote prevention, and tie handling. Perfect for beginners and mini-projects.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages