Home /
Expert Answers /
Computer Science /
the-program-first-reads-integer-certificatecount-from-input-representing-the-number-of-pairs-of-in-pa783
(Solved): The program first reads integer certificateCount from input, representing the number of pairs of in ...
The program first reads integer certificateCount from input, representing the number of pairs of inputs to be read. Each pair has a string and an integer, representing the certificate's holder and level, respectively. One Certificate object is created for each pair and added to vector certificateList. Write the PrintCertificates() function in the RecordsManager class to call each Certificate object's Print() function. Ex: If the input is: 4 Jen 1 Del 12 Wei 6 Meg 13 hen the output is: Certificate: Jen, Level: 1 Certificate: Del, Level: 12 Certificate: Wei, Level: 6 Certificate: Meg, Level: 13 \#include ?iostream? \#include ?vector? using namespace std; class Certificate \{ public: void SetHolderAndLevel(string newHolder, int newLevel); void Print() const; private: string holder; int level; \}; void Certificate::SetHolderAndLevel(string newHolder, int newLevel) \{ holder = newHolder; level = newLevel; \}
void Certificate: :Print() const \{ cout ? "Certificate: " ? holder ? ", Level: " ? level ? endl; \} class RecordsManager \{ public: void Inputcertificates(); void PrintCertificates(); private: vector certificatelist; \}; void RecordsManager: : InputCertificates() \{ Certificate currcertificate; stnine runnulden.
J, void RecordsManager: : InputCertificates() \{ Certificate currcertificate; string currHolder; int currLevel; int certificatecount; unsigned int i; cin ? certificateCount; for ( i=0; i< certificatecount; ++i){ cin ? currHolder; cin ? currLevel; currCertificate.SetHolderAndLevel(currHolder, currLevel); certificatelist.push_back(currCertificate); \} \}
46}I? Your code goes here */ int main() \{ RecordsManager recordsManager; recordsManager. InputCertificates (); recordsManager.PrintCertificates(); return ?; \}