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
Arisa [49]
3 years ago
8

Instructions 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, the number of votes received, 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: 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:
KengaRu [80]3 years ago
8 0

Here is code in java.

import java.util.*;

class Election

{ //main method

   public static void main(String args[]){

      // create an object of Scanner class to read input

      Scanner s = new Scanner(System.in);

      // string array to store name of candidates

       String name[] = new String[5];

       // int array to store vote count of candidates

       int v_count[] = new int[5];

       double p = 0;

       int i = 0, sum = 0, high =0, win = 0;

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

       {

          System.out.print("last name of Candidate " + (i+1) + ":");

          // read name of Candidate

          name[i] = s.next();

          System.out.print(" number of votes received: ");

          // read vote of Candidate

           v_count[i] =s.nextInt();

if(v_count[i] > high)

              {

                  // highest vote

                  high = v_count[i];

                  win = i;

              }

              // total vote count

           sum +=v_count[i];

       }

     // printing the output

      System.out.println("\nCandidate\tVotes Received\t% of TotalVotes\n");

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

       {

           // % of vote of each Candidate

           p =(v_count[i]*100)/sum;

           // print the output

          System.out.println(name[i] + "\t\t" + v_count[i] + "\t\t\t" +p);

       }

       // print the total votes

      System.out.println("\nTotal Votes:\t" + sum);

      // print the Winner of the Election

       System.out.println("Winner of the Election is: " + name[win]);

   }

}

Explanation:

Create a string array "name" to store the name of candidates.Create Integer array "v_count" to store votes os each candidates.Calculate total votes of all candidates and find the highest vote amongst all candidate and print it.Find % of votes received by each candidate.Print these stats.

Output:

last name of Candidate 1:patel

number of votes received: 54

last name of Candidate 2:singh

number of votes received: 76

last name of Candidate 3:roy

number of votes received: 33

last name of Candidate 4:yadav

number of votes received: 98

last name of Candidate 5:sharma

number of votes received: 50

Candidate       Votes Received  % of TotalVotes

patel           54                      17.0

singh           76                      24.0

roy             33                      10.0

yadav           98                      31.0

sharma          50                      16.0

Total Votes:  311

Winner of the Election is: yadav

You might be interested in
How can a user remove or delete a PivotTable? Select the PivotTable and click Clear All in the Actions group under the Options t
Damm [24]

Answer:

-Pick a cell anywhere in the PivotTable to show the PivotTable Tools on the ribbon.

-Click Analyze > Select, and then pick Entire PivotTable.

-Press Delete.

6 0
3 years ago
Read 2 more answers
What is word processing in excel
Flura [38]

Answer:

Microsoft Excel and Microsoft word are the part of the MicrosoftOffice Package of productvity software.

5 0
3 years ago
Who can provide you with a new password when you have forgotten your old one?
Tomtit [17]

Generally there will be a forgot password button, the it will send a link to your email on how to change it, or what the password is.

7 0
3 years ago
Read 2 more answers
Today's Apple Mac computers run with the same internal hardware as the Windows-based PC.
sergejj [24]
I would say yes


If you look at the more modern Mac laptop or the MacBook Pro you will see that the core that is being used is an intel core m3 - m7 which would be a custom take on the intel cores i3 - i7 on an actual windows PC, when you compare them, both cores come from the same company and they both have power that is indicated by their name and rank as well as the motherboards which are made to support the cores which are usually under a 64 - bit architecture as far as my concern goes
6 0
3 years ago
The rules and guidelines for appropriate computer mediated communication are called ________. A. Social norms b. Etiquette c. Ne
horsena [70]

The rules and guidelines for appropriate computer mediated communication are called Netiquette.

<h3>What is Netiquette?</h3>

Netiquette, which is a  blend of  “net” and “etiquette,” refers to the polite  and appropriate behavior  when communicating with others online.

These rules are important as they help to improve  communication skills, prevent misconceptions, and encourage only socially acceptable behavior when working or  collaborating online.

Some of the DOs of Netiquette among others includes:

  • Being mindful of your tone
  • Use of  emoticons
  • Use of good grammar

Some of the DONTs among others includes:

  • Overuse of abbreviations
  • Unnecessary rants/Flaming
  • Overusing  caps

In conclusion Netiquette involves not doing what you would not do in person.

Learn more about Netiquette here:brainly.com/question/998689

3 0
2 years ago
Other questions:
  • You have been doing a lot of web surfing lately as part of your research for your course and along the way you have noticed a gr
    14·1 answer
  • For a typically large organization how many dns servers should you install
    5·1 answer
  • Applying what formatting option to your excel workbook will make it easier to read when printed out?
    13·1 answer
  • In the line of code shape ("classic") which part of the code is the argument
    11·2 answers
  • Janet manages the security of the database servers at the mortgage company where she works. The servers are Windows Server 2016;
    15·1 answer
  • True or false: Your digital footprint is all the information about you online that only you post. Group of answer choices
    12·2 answers
  • When creating an electronic slide presentation, Lee should avoid
    8·1 answer
  • Examine the following output:
    11·1 answer
  • Write a program called array1.cpp file that use either regular for loop or range based for loop to display the contents of the a
    14·1 answer
  • The main part of your program has the following line of code.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!