Create a voting simulator Requirements There are four candid
Solution
#include <iostream>
 #include <stdlib.h>
 #include <ctime>
 using namespace std;
int main(){
     srand ( time(NULL) ); //so that cpp doesnt give same random number everytime
     cout<<\"Welcome to the Election Simulator.\ \ \";
     int p1 = rand() % 100; //creating a random number
     int p2 = p1 + rand() % (100-p1); //creating a random number
     int p3 = p2 + rand() % (100-p2); //creating a random number
    /*Initialising votes for each candidate*/
     int C = 0;
     int T = 0;
     int J = 0;
     int S = 0;
    //iterating through 100 million votes
     for(int i=0; i<100000000; i++){
         int vote = 1+rand()%100;
        if(vote<=p1)
             C++;
         else if(vote>p1 && vote<=p2)
             T++;
         else if(vote>p2 && vote<=p3)
             J++;
         else
             S++;
     }
    //Output
     cout<<\"The Result:\ \ \";
     cout<<\"Candidate C : \"<<C<<\" : \";
     for(int i=0; i<C/1000000; i++){
         cout<<\"*\";
     }
     cout<<\"\ \";
    cout<<\"Candidate T : \"<<T<<\" : \";
     for(int i=0; i<T/1000000; i++){
         cout<<\"*\";
     }
     cout<<\"\ \";
    cout<<\"Candidate J : \"<<J<<\" : \";
     for(int i=0; i<J/1000000; i++){
         cout<<\"*\";
     }
     cout<<\"\ \";
    cout<<\"Candidate S : \"<<S<<\" : \";
     for(int i=0; i<S/1000000; i++){
         cout<<\"*\";
     }
     cout<<\"\ \";
    cout<<\"Total Number of votes: 100000000\";
 }


