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
Please help me i need rn please help​
boyakko [2]

Answer: uty ute reb

Explanation:

3 0
2 years ago
Is Aerospace Engineering a more enjoyable major than Computer Engineering?
sdas [7]

Answer:

This is really all up to opinion and personal preference, meaning everyone would have their own thought on which career they’d enjoy more. However, to find out which one you’d like more you would really have to way the pros and cons. For example, if you did Aerospace engineering you would get to work with the thought of one day your aircraft could make it to the air or your spacecraft could make it to space, which in my opinion seems like it would help with your motivation and joy on the job. While the career of Computer Engineering is more practical and the work you do would be reached by far more people, if you think about it, there are more individuals purchasing computers for their everyday lives than they are purchasing airplanes.

So the decision is really up to you for which career you would like more, but I encourage you to do your research or even find people that have those careers and ask them what they think about it to help with your decision :)

3 0
2 years ago
explain why the intangibility of software systems poses special problems for software project management.
Vaselesa [24]
Unlike other projects like hardware, mechanical works which is tangible it is very easy to identify the progress of the product. But since the product here is software, it is very hard to determine at what phase or progress you are on now. Thus it needs a documentation from someone who are very knowledgeable to be able to know your progress,
4 0
3 years ago
Who invented napier bone and when​
Alinara [238K]

Answer:

<u>Inventor :</u>   John Napier in Year 1617

Explanation:

He was also the inventor of logarithms (which was  invented to aid calculation known as 'Napier's Bones' in 1617.

7 0
3 years ago
Read 2 more answers
Consider the expression 3 * 2 ^ 2 &lt; 16 5 AndAlso 100 / 10 * 2 &gt; 15 - 3. Which operation is performed second?
miss Akunina [59]

Answer:

In the first expression

3 * 4 will be performed second.

In the second expression

10* 2  will be performed second.

Explanation:

In many programming language, there is an operator precedence where the operator (e.g. +, - , * , / etc) will be executed following a specific order. For example, the operator ^ which denotes power will always be executed prior to * or /    and if / and * exist in the same expression, the operator positioned at the left will be executed first.

Hence, in the expression 3*2^2 < 16 , 2 will be powered to 2 (2^2) first and then only multiplied with 3.

In the expression 100 / 10 * 2 > 15 - 3,  100 will be divided by 10 and then only multiplied with 2.

7 0
4 years ago
Other questions:
  • Which of the following statements about moving averages is not true?
    12·1 answer
  • Before text can be formatted you must first
    10·2 answers
  • What activities are the most likely to infect your computer with a virus? Check all that apply
    11·2 answers
  • Help!!! Who is this? Who is it from?
    14·2 answers
  • The Many–Hands Problem makes it difficult to determine who should be held accountable for mistakes since:
    7·1 answer
  • What is the FTC used car rule
    12·1 answer
  • A common approach of networking multiple computers as opposed to a single computer is? called:
    14·1 answer
  • Each generation is set apart from the previous generation because of an innovation.
    6·1 answer
  • Explain the working principle of computer with suitable diagram​
    15·1 answer
  • Importance of software in computer​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!