Need help with c++ (1) Define the class ContactNode per the following specifications: Private data members string contactName string contactPhoneNumber ContactNode* nextNodePtr Constructor with parameters for name followed by phone number  Public member functions GetName() - Accessor GetPhoneNumber() - Accessor  InsertAfter()  GetNext() - Accessor PrintContactNode() Ex: If the name is Roxanne Hughes and the phone number is 443-555-2864, PrintContactNode() outputs: Name: Roxanne Hughes Phone number: 443-555-2864 (2) Define main() to read the name and phone number for three contacts and output each contact. Create three ContactNodes and use the nodes to build a linked list. (1st attached image) (3) Output the linked list using a loop to output contacts one at a time. (2nd attached image) Provided template: #include using namespace std; class ContactNode { public:    /* Declare member functions here */     private:    /* Declare data members here */     }; /* Define member functions here */ int main() {    /* Type your code here. */        return 0; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Need help with c++

(1) Define the class ContactNode per the following specifications:

  • Private data members
    • string contactName
    • string contactPhoneNumber
    • ContactNode* nextNodePtr
  • Constructor with parameters for name followed by phone number 
  • Public member functions
    • GetName() - Accessor
    • GetPhoneNumber() - Accessor 
    • InsertAfter() 
    • GetNext() - Accessor
    • PrintContactNode()
    • Ex: If the name is Roxanne Hughes and the phone number is 443-555-2864, PrintContactNode() outputs:

    • Name: Roxanne Hughes
    • Phone number: 443-555-2864
  • (2) Define main() to read the name and phone number for three contacts and output each contact. Create three ContactNodes and use the nodes to build a linked list. (1st attached image)

  • (3) Output the linked list using a loop to output contacts one at a time. (2nd attached image)

  • Provided template:
  • #include <iostream>
    using namespace std;

    class ContactNode {
    public:
       /* Declare member functions here */
       
    private:
       /* Declare data members here */
       
    };

    /* Define member functions here */

    int main() {
       /* Type your code here. */
       
       return 0;
    }

Ex: If the input is:
Roxanne Hughes
443-555-2864
Juan Alberto Jr.
410-555-9385
Rachel Phillips
310-555-6610
the output is:
Person 1: Roxanne Hughes, 443-555-2864
Person 2: Juan Alberto Jr., 410-555-9385
Person 3: Rachel Phillips, 310-555-6610
Transcribed Image Text:Ex: If the input is: Roxanne Hughes 443-555-2864 Juan Alberto Jr. 410-555-9385 Rachel Phillips 310-555-6610 the output is: Person 1: Roxanne Hughes, 443-555-2864 Person 2: Juan Alberto Jr., 410-555-9385 Person 3: Rachel Phillips, 310-555-6610
Ex:
CONTACT LIST
Name: Roxanne Hughes
Phone number: 443-555-2864
Name: Juan Alberto Jr.
Phone number: 410-555-9385
Name: Rachel Phillips
Phone number: 310-555-6610
Transcribed Image Text:Ex: CONTACT LIST Name: Roxanne Hughes Phone number: 443-555-2864 Name: Juan Alberto Jr. Phone number: 410-555-9385 Name: Rachel Phillips Phone number: 310-555-6610
Expert Solution
Step 1

Algorithm steps to solve the given problem:

  1. Start
  2. Initialize pointers headPtr, currPtr, and lastPtr to null.
  3. Create a loop to take input from user for contact name and phone number.
  4. Create a new ContactNode object and assign it to currPtr.
  5. Check if headPtr is null.
  6. If headPtr is null, assign currPtr to headPtr and lastPtr.
  7. If headPtr is not null, call InsertAfter() method of lastPtr and assign currPtr to lastPtr.
  8. Print the contact list. 8. Create a loop to print the contact list using GetNext() method of currPtr.
  9. Output the result.
  10. Stop.
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education