Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ answers only This assignment should reflect Overloading and Virtual function

ID: 3804864 • Letter: C

Question

C++ answers only

This assignment should reflect Overloading and Virtual functions, virtual classes and dynamic arrays.

For this assignment you will take the results of a recent election for the mayor of a small city and report the results in different formats. The city has three precincts and you can be sure that there will never be more than ten candidates running for the mayor’s position.

First, you must read the results from a data file and store the values using dynamic arrays (pointers). The file has the last name of each candidate and the number of votes received in each of the three precincts on one line. There could be any number of lines in the file so count them as you go.

The first report should include the results in a tabular form, with the total votes for each candidate at the right side of the table, and the totals for each precinct along the bottom.

Use appropriate headings and line up the columns properly. Also print the total number of votes cast in the election.

For the second report, the candidates want to know how they did in each precinct – as a percent of the votes cast in that precinct. Again, print it in tabular form using one decimal place in each of the percentages.

Finally, you must print the results arranged in order from the winner down to the person with the fewest votes. This means that you will have to sort the array holding each candidates totals, keeping the names array in parallel. The report should include only the name of each candidate, the total votes received by that candidate and the percentage of the votes cast in the election for that candidate – arranged in order from largest to smallest. Again, print the percentages with one decimal place.

To be able to create 3 reports, you should create a base class called report with a print function inside it. Make the report an abstract class and let the derived classes implement the code for the print function to print each report.

The candidate can be a class that you can use in your report.

You need to create the input file (mp4election.txt) using the following data:

Please upload the following:

The class .cpp file

The main program

The class .h file

Output File

Lincoln 120 300 400 Parks 100 500 250 Shakespeare 0 30 50 Ghandi 250 100 40 Ashe 300 50 175 Rodriguez 87 118 320 Curie 284 0 112

Explanation / Answer

#include using namespace std; class A { public: virtual void foo(void) const { cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote