Menu

[solved]-Assignment Reflect Overloading Virtual Functions Virtual Classes Dynamic Arrays Assignment Q39010745

CAN SOMEONE HELP ME COMPLETE THIS ASSIGNMENT

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

Election My Mac Elcction | Build Elcction: Failed | Tacy ot 3:02 PM Election dection main.cpp ) main 1#include <iostrean ElecElection My Mac Llectien Build Clection: Failed | Today e: 3:52 PM- K Bection Repert h ) |C| Report DO Election> Election claEleclion)Eleclion ) Report.cpp ) |M Repert1print0 1 Ninclude Report.h Election YBection inelude ciostreans. port: :Report()Election Election Report.cpp ) |M| Report1 : :print 0 Election M vBection 47 Report1: :print ) Rsutat Feporth Void rapart(str

This assignment should reflect Overloading and Virtual functions, virtual classes and dynamic arrays. For this assignment you will take the results ofa 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 recelved 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 votes cast in the election. For the second report, the candidates want to know haw they did in each precinct as a percent of the votes cast in that precinct. Again, print it in tabular farm using one decimal place each of the percentages. Finally, you must print the results arranged in arder 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 from largest to smallest. Again, print the percentages with one decimal place. 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 To be able to create 3 reports, you should create a base class called report with a pure virtual 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 (mpelection.txt) using the following data: Lincoln 120 300 400 Parks 100 500 250 0 30 50 Shakespeare Ghandi 250 100 40 300 50 175 Ashe Radriguez 87 118 320 0 112 Curie 284 Please upload the following: The class.cpp file The main program The class h file Qutput File Election My Mac Elcction | Build Elcction: Failed | Tacy ot 3:02 PM Election dection main.cpp ) main 1#include <iostrean Election Election cude <fstrean> main.cpp 4 #include <sstrean> 5 #include cvector> Denort h 7using nanespace std Report.cpp Praducts 10 int main() t string*candidateArray=new string [ 10] ; 11 string line; Le (“/Users/ASD/Desktop/Election/Election /Results . txt ” ); open( ) ) (mfile.s 15 wle net1ine (nyfile, line)) 17 candidateArray[index]= line: ind 1V 21 myfile.close (; 22 elsef tout “Unable to execu te .txt file”; Use of undeclar while (in put ) ( 28 input>>vatespiti]>votesp2[i]>>votesp3[ i); Use of und 29 6 Dct2Tot+pct2[i] 31 pet3Tat+epet3[i]; 32 ]+pct2[i] +pct3[ i]; t totaltatotti1 35 input>nane[i]; Reporti r1candidateArray, votespl, votesp2, vatesp3); Report3 r3candidateArray): printi r3.print () return ; +Fiter 98666662& R Election My Mac Llectien Build Clection: Failed | Today e: 3:52 PM- K Bection Repert h ) |C| Report DO Election> Election class Repnrt Election Bublici mancpp 4. Report Constructor cannot I Raport reda Report.h id print)@; Report.cpp Produets private: Unknown type name string canidateArray[10]; 10 12 class Repori publie Report public: Missing raturn type for functioan Report1′; did yau mean the canstructor name ‘Ra 2 Missing return type for function Reporti’ ort1 ( ) ; Regort1(string*cand idateArray) ; void print d you mean the canstructor name ‘Rr 20 class Report2 : public Repart public: Roport2() 23 g*candidateArray); Unknown type name roid print 26 class Rcpor3 public Report publi Missing return type for tunction ‘Repert3’; did you mean the constructor neme ‘Re 2 Missing return typa for function ‘Raport3’; did you mean the constructor name ‘Ro Reports() Report3(stringecandidateArrav): void print( Fiter Eleclion)Eleclion ) Report.cpp ) |M Repert1print0 1 Ninclude Report.h” Election YBection inelude ciostreans. port: :Report() Repert h A A. Fepert.cpp Products 2 Out-af-ine definition pf ‘Report daes not match any declaration in ‘Report Report : :Reaort (stringsc) 10 canidateArray c 13 13X 16 ReportiReport1) Repert (I Use of urdeclared identifier ‘Report1 Report1::Report1( stringec) Report ( stringec) 2 Unknown type name ‘string Report2: : Rapart2( ) : Raport () Report2::Report2istringec) Report(string-c) 30 Out-of-line definition of ‘Report2 dees not match eny declaration in ‘Report2 Use of undaclared Identitier ‘Ronorts Report 3: : Repart3( ) Report Report3: : ReportS(string=c) : Report(stringec) Use of undeclared identifler ‘epor13 Election Election Report.cpp ) |M| Report1 : :print 0 Election M vBection 47 Report1: :print ) Rsutat Feporth Void rapart(string nanc(),int poti[), int pet2[], int pct3[ ], int petıTot, int pot2Tot , int pet3Tot, int tot[], int n,int total) { int i .. Report.cpp 5% Products eutee!Candidato procint 1 arecint 2 precint 3 tatal n”; for ti-; s 12)<enane [i] c<setw (12 ) <<right < <pct1[i]<ssetw (12) xpct2[i] cesatw(12) cepcts[i]cesatw( 12) <stot [i ] ccendl; . a rt3Totsestw(12)<stotal otecsetwl12) 58 61 Report2::print () Void rapart2string namell, int pcti[],int pct2[],int pet3[), int pctlTot , int pct2Tot, int pot3Tot, int n) { int i; tganddote procict 1 arecint 2 precint 3n”; for i-8;i<n;14+) 6 ecision (1 ) xtixed cepet i[ i] +1E Tixedkpct2til+1e. pct2Toteceetel12) <<setprecision(1) -/petiTat <esetw(12) <ssetorecision(1). Report 3: : print ) void repart3( ) int i teeandidato vetes pcrcent at vatesn'”; for (i-a:ien;1++) rightsetatf1eesatwi121cesetorenisinnla .. <fixed<etotli]+100. / totalcendl; Fitor Show transcribed image text This assignment should reflect Overloading and Virtual functions, virtual classes and dynamic arrays. For this assignment you will take the results ofa 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 recelved 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 votes cast in the election. For the second report, the candidates want to know haw they did in each precinct as a percent of the votes cast in that precinct. Again, print it in tabular farm using one decimal place each of the percentages. Finally, you must print the results arranged in arder 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 from largest to smallest. Again, print the percentages with one decimal place. 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 To be able to create 3 reports, you should create a base class called report with a pure virtual 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 (mpelection.txt) using the following data: Lincoln 120 300 400 Parks 100 500 250 0 30 50 Shakespeare Ghandi 250 100 40 300 50 175 Ashe Radriguez 87 118 320 0 112 Curie 284 Please upload the following: The class.cpp file The main program The class h file Qutput File
Election My Mac Elcction | Build Elcction: Failed | Tacy ot 3:02 PM Election dection main.cpp ) main 1#include Denort h 7using nanespace std Report.cpp Praducts 10 int main() t string*candidateArray=new string [ 10] ; 11 string line; Le (“/Users/ASD/Desktop/Election/Election /Results . txt ” ); open( ) ) (mfile.s 15 wle net1ine (nyfile, line)) 17 candidateArray[index]= line: ind 1V 21 myfile.close (; 22 elsef tout “Unable to execu te .txt file”; Use of undeclar while (in put ) ( 28 input>>vatespiti]>votesp2[i]>>votesp3[ i); Use of und 29 6 Dct2Tot+pct2[i] 31 pet3Tat+epet3[i]; 32 ]+pct2[i] +pct3[ i]; t totaltatotti1 35 input>nane[i]; Reporti r1candidateArray, votespl, votesp2, vatesp3); Report3 r3candidateArray): printi r3.print () return ; +Fiter 98666662& R
Election My Mac Llectien Build Clection: Failed | Today e: 3:52 PM- K Bection Repert h ) |C| Report DO Election> Election class Repnrt Election Bublici mancpp 4. Report Constructor cannot I Raport reda Report.h id print)@; Report.cpp Produets private: Unknown type name string canidateArray[10]; 10 12 class Repori publie Report public: Missing raturn type for functioan Report1′; did yau mean the canstructor name ‘Ra 2 Missing return type for function Reporti’ ort1 ( ) ; Regort1(string*cand idateArray) ; void print d you mean the canstructor name ‘Rr 20 class Report2 : public Repart public: Roport2() 23 g*candidateArray); Unknown type name roid print 26 class Rcpor3 public Report publi Missing return type for tunction ‘Repert3’; did you mean the constructor neme ‘Re 2 Missing return typa for function ‘Raport3’; did you mean the constructor name ‘Ro Reports() Report3(stringecandidateArrav): void print( Fiter
Eleclion)Eleclion ) Report.cpp ) |M Repert1print0 1 Ninclude Report.h” Election YBection inelude ciostreans. port: :Report() Repert h A A. Fepert.cpp Products 2 Out-af-ine definition pf ‘Report daes not match any declaration in ‘Report Report : :Reaort (stringsc) 10 canidateArray c 13 13X 16 ReportiReport1) Repert (I Use of urdeclared identifier ‘Report1 Report1::Report1( stringec) Report ( stringec) 2 Unknown type name ‘string Report2: : Rapart2( ) : Raport () Report2::Report2istringec) Report(string-c) 30 Out-of-line definition of ‘Report2 dees not match eny declaration in ‘Report2 Use of undaclared Identitier ‘Ronorts Report 3: : Repart3( ) Report Report3: : ReportS(string=c) : Report(stringec) Use of undeclared identifler ‘epor13
Election Election Report.cpp ) |M| Report1 : :print 0 Election M vBection 47 Report1: :print ) Rsutat Feporth Void rapart(string nanc(),int poti[), int pet2[], int pct3[ ], int petıTot, int pot2Tot , int pet3Tot, int tot[], int n,int total) { int i .. Report.cpp 5% Products eutee!Candidato procint 1 arecint 2 precint 3 tatal n”; for ti-; s 12)

Expert Answer


Answer to This assignment should reflect Overloading and Virtual functions, virtual classes and dynamic arrays. For this assignmen… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *