Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes received by each candidate. The program should then output each candidate’s name (candidate), the number of votes received (votes received), and the percentage of the total votes received by the candidate (% of total votes). Your program should also output the winner of the election

Respuesta :

The  program allows the user to enter the last names of five candidates is

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

   string candidate1, candidate2, candidate3, candidate4, candidate5;

   int votes1, votes2, votes3, votes4, votes5, totalVotes;

   double percentage1, percentage2, percentage3, percentage4, percentage5;

   // Prompt user to enter the last name of five candidates

   cout << "Enter the last name of five candidates: ";

   cin >> candidate1 >> candidate2 >> candidate3 >> candidate4 >> candidate5;

   // Prompt user to enter the number of votes received by each candidate

   cout << "Enter the number of votes received by each candidate: ";

   cin >> votes1 >> votes2 >> votes3 >> votes4 >> votes5;

   // Calculate the total number of votes

   totalVotes = votes1 + votes2 + votes3 + votes4 + votes5;

   // Calculate the percentage of the total votes received by each candidate

   percentage1 = (votes1 / static_cast<double>(totalVotes)) * 100

For more questions like Program click the link below:

https://brainly.com/question/13706759

#SPJ4