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]
4 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]4 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
Which type of user profile is stored in the C:\Users folder and is automatically created when a user logs on to the computer for
Sladkaya [172]

Answer:

a. Local user profile.

Explanation:

Local user profile is a type of user profile which is stored in the C:\Users folder and is automatically created when a user logs on to the computer for the first time and it is being stored on the local hard disk of the computer.

Generally, in Microsoft windows any change made to the local user profile is peculiar to the user and the host computer on which the change is made.

Hence, local user profiles avails several users the opportunity of sharing a single computer with their respective user settings and data.

3 0
3 years ago
How can an administrator initiate a system state recovery using the command line?
LUCKY_DIMON [66]

A leader creates a system state recovery utilizing the power cord wbadmin start system state recovery.

<h3>What is the power to start a system state restoration?</h3>
  • Windows has a built-in tool that lets you back up and repairs a server's system state, which is quick and easy to use.
  • The Wbadmin can be operated with the Start System State Backup order to create a blockage of the system state for a computer and the Start System State Recovery order to restore the system state.
  • Use the order -backuptarget:\\servername\sharedfolder\ to store system state backups.
  • Runs the power without prompts to the user.
  • The System State information reference in Backup Manager lets you support the design of your working system and vital system features such as the Registry, boot files, SYSVOL directory, and Active Directory.

To learn more about, start system state recovery, refer to:

brainly.com/question/24180931

#SPJ4

4 0
2 years ago
given the numerical value 1010101.11, which of the following number systems is most likely represented.
nasty-shy [4]

Answer:

u have to give me more points

Explanation:

sorry

7 0
3 years ago
Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the g
Tatiana [17]

Answer:

const double gasDollarPerGallon = 20 ;

float calCost( double milesPerGallon ) {

   double costPerGallon = milesPerGallon / gasDollarPerGallon;

   System.out.printf ("%.2f/n", &costPerGallon);

int main ( ) {

   scanf ("%2f", &gasDollarPerGallon) ;

   calCost( 20 );

   calCost( 75 );

   calCost( 500 );

Explanation:

The C source code above gets the user input of the gas dollar per gallon from the command prompt and divides the miles per gallon variable in the function call to get the cost of gas for the range of miles. It is also print out as a double with two places.

4 0
3 years ago
Read 2 more answers
Please choose odd one out please tell fast​
nikdorinn [45]

Answer: arrow key

Explanation:

3 0
3 years ago
Other questions:
  • What causes air pollution in your community?
    13·1 answer
  • c) Do hardware purchases or salaries for IT workers demand a greater share of the total cost of the ownership of the IT infrastr
    9·2 answers
  • On an unweighted scale, a grade of A is worth _____ points
    7·1 answer
  • Which of the following does Moore's law predict?
    15·1 answer
  • Using the employment websites, search for part-time jobs that relate to the career fields you are interested in pursuing or to y
    12·2 answers
  • When is a handrail required for stairs
    12·2 answers
  • What is typeface
    11·2 answers
  • How do I put in a micro sd card that is in a sd adapter in to my laptop to make it work PLEASE HELP
    10·1 answer
  • Internet speed test, why does it take some time to get maximum speed
    14·1 answer
  • What is the significance of the scientific method?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!