EVM machine project in c++ - Algomentor

EVM machine project in c++


Hi, friends in this article we do a mini project in c++ name of the project is EVM machine project in c++ you can use this mini project in c++. you can use this mini project in school or university 1st-year project. and after learning and doing this project you will master many concepts in c++ in many ways.

evm machine project in c++

What is a project?

project is something that you create after learning some theoretical knowledge and implement some good things practical.

Why should we do the project regularly?

after reading the above question you know what is the importance of the project but when we do regular practice it will make our concept stronger and keep train our brain to think more in logic and coding.

There is some prerequisite before starting the project you should know basic of these concepts.
  • Data types in c++
  • Conditional statements in c++
  • Loop in c++ especially for loop
  • File system in c++
If you don't know about this topic please learn these because these are some important topics to understand this project completely.

Basic idea about this project:- In this project, we make a voting machine in which we have 4 different option to vote each user vote one time and after all the user gives their vote we will conclude the result and store in our file and we have a full-fledged file in which we store a list of winner party for every year.

So, Now we will discuss many things about the project so I think we should move into the coding part of the project after the project source code. I will give you a complete explanation of the project.

Here is the code of the EVM machine project in c++.

#include <iostream>
#include <fstream>
using namespace std;

int main()
{
    string year;
    int i,n,v,b=0,c=0,a=0,ip=0,no=0;
    cout<<endl;
    cout<<"     ***************************"<<endl;
    cout<<"     ****       E-V-M       ****"<<endl;
    cout<<"     ***************************"<<endl<<endl;
    cout<<"   Enter the year in which election is held :-> ";
    cin>>year;
    cout<<endl;
    cout<<"     ******************************************"<<endl;
    cout<<"     * 1 :->   BHARTIYA JANTA PARTY (B-J-P)   *"<<endl;
    cout<<"     * 2 :-> INDIAN NATIONAL CONGRESS (I-N-S) *"<<endl;
    cout<<"     * 3 :->    AAM ADAMI PARTY (A-A-P)       *"<<endl;
    cout<<"     * 4 :->    INDIPENDENT PARTY (I-P)       *"<<endl;
    cout<<"     ******************************************"<<endl<<endl;
    cout<<"     Enter the number of voter :-> ";
    cin>>n;

    fstream out;
    out.open("file.txt",ios::app);
    out<<"           Election held in year "<<year<<endl<<endl;
    out<<"   Total no of voter is "<<n<<endl;
    cout<<endl<<" Select your vote between 1 to 4"<<endl<<endl;
    for(i=0; i<n; i++)
    {
        cout<<"voter no "<<i+1<<" enter your vote :-> ";
        cin>>v;
        if(v==1)
            b++;
        else if(v==2)
            c++;
        else if(v==3)
            a++;
        else if(v==4)
            ip++;
            else
            no++;
    }
    cout<<endl;
    out<<"   Total no of vote scored by B-J-P is "<<b<<endl;
    out<<"   Total no of vote scored by I-N-S is "<<c<<endl;
    out<<"   Total no of vote scored by A-A-P is "<<a<<endl;
    out<<"   Total no of vote scored by I-P is "<<ip<<endl<<endl;

   if(b>c && b>a && b>ip)
   {
      cout<<" B-J-P win the election by scoring "<<b<<" votes"<<" out of " <<n<<endl;
      out<<" B-J-P win the election by scoring "<<b<<" votes"<<" out of " <<n<<endl;
   }
   else if(c>b && c>a && c>ip)
   {
      cout<<" I-N-C win the election by scoring "<<c<<" votes"<<" out of " <<n<<endl;
      out<<" I-N-C win the election by scoring "<<c<<" votes"<<" out of " <<n<<endl;
   }
   else if(a>b && a>c && a>ip)
   {
      cout<<"  A-A-P win the election by scoring "<<a<<" votes"<<" out of " <<n<<endl;
       out<<"  A-A-P win the election by scoring "<<a<<" votes"<<" out of " <<n<<endl;

   }
   else if(ip>a && ip>c && ip>b)
   {
      cout<<"  I-P win the election by scoring "<<ip<<" votes"<<" out of " <<n<<endl;
      out<<"  I-P win the election by scoring "<<ip<<" votes"<<" out of " <<n<<endl;
   }
   else if (b==c || b==a || b==ip || c==a || c==ip || a==ip)
   {
       cout<<"  The election is draw  "<<endl;
       out<<"  The election is draw  "<<endl;
   }
   else{

   }
   out<<endl<<"****************************************************"<<endl<<endl;
   out.close();
}

I hope you rear the project source code very carefully and tried in your compiler also. and you have some related doubt also. so now we will discuss every aspect of the project and how we made it. but before that, I highly recommend that you should try this project source code in your local PC and try to understand this on your own. If you still don't get it then read the helping note on the project.

Helping Note for this mini-project
  • First, we declare two header files one for input-output and another for the file operation.
  • Then we take input of the year in which election held.
  • Then we list the party present of the election in my case there are four parties.
  • Then we take how many users participate in the election and run for loop accordingly.
  • And after running for loop we have how many vote each party get we did help of condition statement and variables.
  • After that, with the help of conditional statements, we will find which parties have maximum number of votes.
  • And after that, we print result on the screen and at the same time we store the result in the file as well
  • And after this, we will terminate the program and we will check file for older result info.
Hope you like our this project article on our website do follow our Facebook page we will update them regularly. so you get regular updates of the project and many concepts in c++ and java.

Thank you very much for reading this article and if you find this article meaningful then please share with your friends so that they can also learn from somethings. keep doing a project and always learning something from them.

And if you want to contact us you can use our contact form shown on the right side of the computer and at the bottom of the mobile phone you can write your message there and we will reply accordingly.

If you want to write a post on our website then please check this article on How to do a guest post.

Post a Comment

0 Comments