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

The class NameType consists of 4 instance data: string title, string first, stri

ID: 3826913 • Letter: T

Question

The class NameType consists of 4 instance data: string title, string first, string middle, string last. The class has a constructor that is passed all four string values and initializes the class appropriately, and has four functions, each returns one of the four instance data: called returnTitle( ), returnFirst( ), returnMiddle( ) and returnLast( ). NameType addressBook[100]; is declared. Write a function called countGivenName that is passed two string parameters corresponding to a NameType's first and last, and finds the total number of entries in addressBook that has the same first name and last name as these parameters. The function then returns the total count.

Explanation / Answer

Hi, Please find my defination of required functions.

Please let me know in case of any issue.

int NameType::countGivenName(string first, string last){
  
   int count = 0;
   for(int i=0; i<100; i++){

       if(addressBook[i].first == first && addressBook[i].last == last)
           count++;
   }

   return count;
}

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