I have a couple of questions, regarding my program:
-----------------------------------------------------------
#1: Is it possible to have my table centered? The table is located towards the bottom of my console output and, as you can see, the data is sort of off center.
#2: Instead of having the user input five names and five int values, would it be possible to simply enter this data into my template at the bottom? If so, how would I go about doing that? To clarify: One may be able to (easily) create a loop which allows the user to input a name and integer value; however, in order for % of total votes to be calculated, all the data must be known.
------------------------------------------------------------
Program code:
------------------------------------------------------------

#include <cstdlib>
#include <iomanip>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{int index=0,listsize=5,maxindex=1,votes[5];
float sum=0;
string candidates[5];
cout<<"Enter last name of candidate: "<<endl;
for(index=0;index<listsize;index++)  
{cin>>candidates[index];}
cout<<endl;                      
cout<<"Enter votes received for corresponding candidate: "<<endl;
for(index=0;index<listsize;index++)
{cin>>votes[index];
sum=sum+votes[index];}
cout<<endl<<"Results of the election:"<<endl<<endl;
cout<<"Candidate"<<"     "<<"Votes Received"<<"     "<<"Percent of Total Votes"
<<endl<<endl;
for(index=0;index<listsize;index++)
{cout<<candidates[index]<<"          "<<votes[index]<<"                  "
<<setprecision(4)<<
((votes[index]/sum)*100)<<endl;}
cout<<"Total          "<<static_cast <int> (sum)<<endl<<endl<<endl;
for(index=0;index<listsize;index++)
{if(votes[maxindex]<votes[index])
maxindex=index;}
cout<<"The winner of the election is: "<<candidates[maxindex]<<"."<<endl;
cout<<"The winner was found at position "<<maxindex<<" in the array."<<endl;
system("PAUSE");
return EXIT_SUCCESS;}

------------------------------------------------------------
My console output:
------------------------------------------------------------
Enter last name of candidate:
Johnson
Miller
Duffy
Robinson
Ashtony

Enter votes received for corresponding candidate:
5000
4000
6000
2500
1800

Results of the election:

Candidate Votes Received Percent of Total Votes

Johnson 5000 25.91
Miller 4000 20.73
Duffy 6000 31.09
Robinson 2500 12.95
Ashtony 1800 9.326
Total 19300


The winner of the election is: Duffy.
The winner was found at position 2 in the array.
Press any key to continue . . .
------------------------------------------------------------
You can also view my output by clicking on: http://i584.photobucket.com/albums/ss284/sear_squid/output.png

> Is it possible to have my table centered?

Yes. See: http://www.cprogramming.com/tutorial/iomanip.html

> would it be possible to simply enter this data into my template at the bottom?
> If so, how would I go about doing that?

The standard C++ library provides no facilities for doing this. You would need to use a library like curses.
http://en.wikipedia.org/wiki/Curses_%28programming_library%29

Don't think you should be bothering about this right now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.