I am new to programming. I have the below code and It need to output the vote, percentage, winner, and total. I am totally lost please assist:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct electionList
{
void print() const;
void voteTotal();
void solvePercentage();
void calcWinner();
int votes[100];
double percentage[100];
string candidates[2];
int count;
int total;
};
//CALCULATES TOTAL AMOUNT OF VOTES FOR EACH CANDIDATE
void electionList::print() const
{
cout<<"Candidate"<<"Votes Received"<<"% of Votes"<<endl;
for (int i=0; i<count; i++)
{
cout<<candidates[i];
cout<<votes[i];
cout<< percentage[i];
}
cout<<"Total"<<total<<endl;
}
void electionList::voteTotal()
{
int total;
for (int i=0; i<count; i++)
{
total = total + votes[i];
}
}
//CALCULATES PERCENTAGE OF VOTES FOR EACH CANDIDATE
void electionList::solvePercentage()
{
for (int i=0; i<count; i++)
{
percentage[i] = ((votes[i]/total)*(100));
}
}
//cOMPARES NUMBER OF VOTES FOR WINNER
void electionList::calcWinner()
{
string winner = candidates[0];
int max = votes[0];
for (int i=0; i<count; i++)
{
if(votes[i]>max)
{
max = votes[i];
winner = candidates[i];
}
}
};
int main()
{
electionList election;
electionList insert();
string name;
int count;
int tally;
string candidate[100];
int votes[100];
//INPUT DATA
cout<<"Enter the number of candidates: ";
cin>> count;
for (int i=0; i<count; i++)
{
cout<<"Enter name and amount";
cin>>name>>tally;
candidate[i]=name;
votes[i]=tally;
//candidate->insert(i,name)>>votes->insert(i, votes);
}
count = 1;
candidate[1]="thomas";
votes[1] = 300;
cout<<candidate[1]<<votes[1];
// OUTPUT RESULTS
cout<<"election result";
election.print();
cout<<"election vote total";
election.voteTotal();};