1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Triss [41]
3 years ago
12

Write a program that allows the user to enter the last names of five candidates in a local election and the votes received by ea

ch candidate. The program should then output each candidate’s name, the votes received by that candidate. Your program should also output the winner of the election. A sample output is: Candidate Votes Received % of Total Votes Johnson 5000 25.91 Miller 4000 20.73 Duffy 6000 31.09 Robinson 2500 12.95 Ashtony 1800 9.33 Total 19300 The Winner of the Election is Duffy.
Computers and Technology
1 answer:
blsea [12.9K]3 years ago
7 0

Answer:

#include <iostream>

#include <string>

using namespace std;

int main()

{

   string names[5];

   int votes[5];

   for(int i=0;i<5;i++)

   {

       cout<<"Enter candidate name"<<endl;

      getline(cin,names[i]);

       cout<<"Enter candidate votes"<<endl;

       cin >> votes[i];

 cin.ignore();

   }

int total_votes=0;

int max =-1;

int max_val=0;

for(int i=0;i<5;i++)

   {

       total_votes=total_votes+votes[i];

       if(max_val<votes[i])

       {

           max_val=votes[i];

           max=i;

       }

       

   }

   cout<<"Total votes"<<total_votes<<endl;

   for(int i=0;i<5;i++)

   {

       float per=(votes[i]/total_votes)*100;

       cout<<"float per"<<per<<endl;

       cout<<" "<<names[i]<<" "<<votes[i]<<" "<<per<<" %" <<endl;

   }

       cout<<"Winner is  "<<names[max]<<" "<<votes[max]<<endl;

   return 0;

}

Explanation:

Define a string array of size 5 for names. Define one integer array of size 5 for votes. Take input from user in loop for string array and int for votes.

In another loop find maximum of the list and sum all the votes. Store max votes index in max variable. In another loop display names along with their votes and percentage.

Display winner name and votes using max as index for name and votes array.

You might be interested in
All it services and servers are equally critical. <br> a. True <br> b. False
g100num [7]

False

Not all IT services are equally critical. In an increasingly digital world whereby cyber threats are a big threat, it is vital to prioritize the critical assets in order to achieve digital resilience. This involves building tighter defenses in systems that are critical.

4 0
3 years ago
Citations that are ______________________________ can be used to build a bibliography when needed. [Create and Modify Citation S
VMariaS [17]

Answer:

I think the best option would be C. Marked

Explanation:

hope this helps and sorry if it is incorrect.

8 0
3 years ago
Describe the Pros and Cons Associated with Cloud Computing Cloud Computing was introduced in 1999 by a company named "Salesforce
Rudik [331]

Answer & Explanation:

Pros of cloud computing:

  • Cloud computing provides high speed due to faster deployment of services in fewer clicks.
  • It eliminates the need of IT infrastructure and manageability.
  • It is cost efficient as it provides huge space availability.
  • It makes it easy to get backup and recovery.
  • It is easy to access information anytime and anywhere in the world.
  • Due to cloud computing, it is very easy to add or remove services as required.

Cons of cloud computing:

  • It makes the data vulnerable and information theft challenges can be encountered.
  • Internet connection is required all the time.
  • There is less control available as it runs on remote servers.
  • Migrating information can become difficult.
  • It can face technical issues so the information will not be available for a limited time.
7 0
3 years ago
Omar sends a PDF file to his teacher. He then prepares another copy of the presentation that includes only the slides he wants t
maria [59]

Answer:

D. Custom Slide Show

Explanation:

Correct on edg

7 0
3 years ago
An informative presentation can be used for conducting a classroom discussion.
Dmitrij [34]

Answer:

I think you have to ask you're teacher, not brainly because people on here can't answer this for you

3 0
2 years ago
Other questions:
  • In a mission critical environment, performing maintenance operations on a host FIRST requires which of the following?
    6·1 answer
  • Operating systems are designed to work with specific hardware. Which operating system works with Apple computers?
    8·2 answers
  • Assume that two classes 'Temperature' and 'Sensor' have been defined. 'Temperature' has a constructor that accepts a double para
    15·1 answer
  • Which of the following commands is more recommended while creating a bot?
    9·1 answer
  • What is a bug?
    11·2 answers
  • 1. Given a sequential list with n numbers, represented in a one-dimensional array A) Write an algorithm to check if the list has
    14·1 answer
  • ________ is a remote access client/server protocol that provides authentication and authorization capabilities to users who are
    10·1 answer
  • During detachment, _____.
    12·2 answers
  • Explain the steps in starting the MS Access from the Start Menu.​
    9·1 answer
  • _____ oversee the work of various types of computer professionals and must be able to communicate with people in technical and n
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!