Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program That allows the user to enter the last names of five candida

ID: 3772045 • Letter: W

Question

Write a C++ program
That allows the user to enter the last names of five candidates
in a local election and the votes received by each candidate. The program should
then output each candidate’s name, votes received by that candidate, and the
percentage of the total votes received by the candidate. Your program should also
output the winner of the election. A sample output is as follows:


Candidate   Votes Received       % of Total Votes
---------   --------------       ----------------
Johnson       5000           25.91
Miller       4000           20.72
Duffy       6000           31.09
Robinson   2500           12.95
Sam       1800           9.33

Total       19300

The Winner of the Election is Duffy.

==============================================================

I need original code and not something copied exactly off the Internet

Not a copy of the code from any of these sites or elsewhere online.

http://www.cplusplus.com/forum/beginner/47746

http://jozefg.ecs.fullerton.edu/public/CS901/delete2/P5_ch13_exc3_Dynamic_Arrays_Votes_error_handling_doc_G+/Election-2dArray/election.cpp

http://www.dreamincode.net/forums/topic/36915-candidate-program

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0ahUKEwi1k8D1zMrJAhVL_mMKHa0mDY4QFgglMAE&url=http%3A%2F%2Fjozefg.ecs.fullerton.edu%2Fpublic%2FCS901%2FAssignment.doc&usg=AFQjCNFqYPew_taXdvkpx-CyUxWpfn6lDw&sig2=_FWD7Bi6Ly1T0A8NRDElcA&cad=rja

https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0ahUKEwi1k8D1zMrJAhVL_mMKHa0mDY4QFgglMAE&url=http%3A%2F%2Fjozefg.ecs.fullerton.edu%2Fpublic%2FCS901%2FAssignment.doc&usg=AFQjCNFqYPew_taXdvkpx-CyUxWpfn6lDw&sig2=_FWD7Bi6Ly1T0A8NRDElcA&cad=rja


Just looking for unique code that can't be found online at a bunch of sites already

Thanks much

Explanation / Answer

#include<iostream.h>
#include<conio.h>

void main()
{
   string name[5];
   int votes[5],i,ind,tot=0;

   for(i=0i<5;i++)
   {
       cout<<"Enter name";
       cin>>name[i];

       cout<<"Enter votes";
       cin>>votes[i];
       tot=tot+votes[i];

   }
  
   for(i=0;i<5;i++)
   {
       cout<<name[i]<<" "<<votes[i]<<" "<<tot/votes[i]<<endl;
   }
   cout<<"Total"<<tot;
   int max=0;

   for(i=0;i<5;i++)
   {
       if(votes[i]>max)
       {
           max=votes[i];
           ind=i;
       }
   }
   cout<<The Winner of the Election is "<<name[ind];
   getch();
}
  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote