Write a program that helps to calculate total votes of student representatives in a college. The program also finds the

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Write a program that helps to calculate total votes of student representatives in a college. The program also finds the

Post by answerhappygod »

Write A Program That Helps To Calculate Total Votes Of Student Representatives In A College The Program Also Finds The 1
Write A Program That Helps To Calculate Total Votes Of Student Representatives In A College The Program Also Finds The 1 (179.51 KiB) Viewed 54 times
Write a program that helps to calculate total votes of student representatives in a college. The program also finds the highest votes and displays the winner. There are 3 selected candidates and 4 student clubs that will participate in the selection. . In the class: Create a static String array with the candidates' name which are: Anna, Kristy and Robin. Create a static String array with the clubs' name which are: Chess, Archery, Badminton and Music. [Note: static variable: a single copy of variable is created and shared among all objects at class level. Static variables are, essentially, global variables] In the main method: Create a 2D array of int values for the votes based on the 3 candidates and 4 clubs. Create an int array to store the total votes for each candidate. Prompt the user to enter the votes for the candidates from each clubs. Call method get Totalvotes and pass the 2D array and the total votes array (10) as the arguments. Calculate the total votes and display the total votes for each candidate. This method is not returning any value. Then call method getWinner pass the array total as the parameter. The method finds the highest votes and displays the winner name. This method is not returning any value. Refer to the sample output as shown below: run: Enter the votes for the candidate: Candidate 1: Anna From club Chess = 25 From club Archery = 24 From club Badminton = 37 # From club Music = 27 #-User input Candidate 2: Kristy From club Chess = 20 From club Archery = 35 From club Badminton = 23 From club Music = 40 # # From method getTotalVotes) Candidate 3: Robin From club Chess = 43 From club Archery = 20 From club Badminton = 30 From club Music = 32 # The Result Candidate 1: Anna, Total Votes = 113 Candidate 2: Kristy, Total Votes = 118 Candidate 3: Robin, Total Votes = 125 The winner is Robin From method
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply