Hello I need some help with my CC+ project.
My current project erasing the first two phone numbers and only printing the 3rd phone number out in the list. Any idea on how to correct.
Here is the error.

Contacts.h
#ifndef Contact_H
#define Contact_H
#include<string>
using namespace std;
class ContactNode{
public:
ContactNode();
ContactNode(string name, string phone);
void InsertAfter(ContactNode*);
string GetName();
string GetPhoneNumber();
ContactNode* GetNext();
void PrintContactNode();
private:
string contactName;
string contactPhoneNum;
ContactNode* nextNodePtr;
};
#endif
Contacts.cpp
#include <iostream>
#include "Contacts.h"
using namespace std;
ContactNode::ContactNode(){
nextNodePtr=NULL;
}
ContactNode::ContactNode(string name, string phoneNum){
contactName=name;
contactPhoneNum=phoneNum;
nextNodePtr=NULL;
}
void ContactNode::InsertAfter(ContactNode *nextNode){
ContactNode *temp;
if(nextNodePtr==NULL)
nextNodePtr=nextNode;
else{
temp=nextNodePtr;
while(temp->nextNodePtr!=NULL){
temp=temp->GetNext();
}
temp->nextNodePtr=nextNode;
}
}
string ContactNode::GetName(){
return contactName;
}
string ContactNode::GetPhoneNumber(){
return contactPhoneNum;
}
ContactNode* ContactNode::GetNext(){
return nextNodePtr;
}
void ContactNode::PrintContactNode(){
ContactNode *temp;
if(nextNodePtr!=NULL) {
cout<<"Contact Name: "<<nextNodePtr->GetName()<<endl;
cout<<"Phone number: "<<nextNodePtr->GetPhoneNumber()<<endl<<endl;
GetNext()->PrintContactNode();
}
}
Main.cpp
#include <iostream>
#include "Contacts.h"
using namespace std;
int main()
{
ContactNode *List,*head;
string Name;
string PhoneNum;
List=new ContactNode;
for(int i=0;i<3;i++){
cout<<"Person " <<i+1<<endl;
cout<<"Enter name: "<<endl ;
getline(cin, Name);
cout<<"Enter phone number: "<<endl ;
cin>>PhoneNum ;
getline(cin, PhoneNum);
cout<<"You entered: "<<Name<<", "<< PhoneNum<<endl<<endl ;
List->InsertAfter(new ContactNode(Name,PhoneNum));
}
cout<<endl<<endl<<"CONTACT LIST"<<endl<<endl;
List->PrintContactNode();
system("pause");
return 0;
}
Here is the full assignment details if there is any futher questions
This program needs to be completed in C++.
(1) Create three files to submit.
Contacts.h - Class declaration
Contacts.cpp - Class definition
main.cpp - main() function
(2) Build the ContactNode class per the following specifications:
Parameterized constructor. Parameters are name followed by phone number.
Public member functions
InsertAfter() (2 pts)
GetName() - Accessor (1 pt)
GetPhoneNumber - Accessor (1 pt)
GetNext() - Accessor (1 pt)
PrintContactNode()
Private data members
string contactName
string contactPhoneNum
ContactNode* nextNodePtr
Ex. of PrintContactNode() output:
Name: Roxanne Hughes Phone number: 443-555-2864
(3) In main(), prompt the user for three contacts and output the
user's input. Create three ContactNodes and use the nodes to build
a linked list. (2 pts)
Ex:
Person 1 Enter name: Roxanne Hughes Enter phone number: 443-555-2864 You entered: Roxanne Hughes, 443-555-2864 Person 2 Enter name: Juan Alberto Jr. Enter phone number: 410-555-9385 You entered: Juan Alberto Jr., 410-555-9385 Person 3 Enter name: Rachel Phillips Enter phone number: 310-555-6610 You entered: Rachel Phillips, 310-555-6610
(4) Output the linked list. (2 pts)
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-661
C++:
main.cpp:
#include <iostream>
#include "Contacts.h"
using namespace std;
int main()
{
ContactNode *List,*head;
string Name;
string PhoneNum;
List=new ContactNode;
for(int i=0;i<3;i++){
cout<<"Person " <<i+1<<endl;
cout<<"Enter name: "<<endl ;
getline(cin, Name);
cout<<"Enter phone number: "<<endl ;
getline(cin, PhoneNum);
cout<<"You entered: "<<Name<<", "<<
PhoneNum<<endl<<endl ;
List->InsertAfter(new ContactNode(Name,PhoneNum));
}
cout<<endl<<endl<<"CONTACT
LIST"<<endl<<endl;
List->PrintContactNode();
return 0;
}
Contacts.cpp:
#include <iostream>
#include "Contacts.h"
using namespace std;
ContactNode::ContactNode(){
nextNodePtr=NULL;
}
ContactNode::ContactNode(string name, string phoneNum){
contactName=name;
contactPhoneNum=phoneNum;
nextNodePtr=NULL;
}
void ContactNode::InsertAfter(ContactNode *nextNode){
ContactNode *temp;
if(nextNodePtr==NULL)
nextNodePtr=nextNode;
else{
temp=nextNodePtr;
while(temp->nextNodePtr!=NULL){
temp=temp->GetNext();
}
temp->nextNodePtr=nextNode;
}
}
string ContactNode::GetName(){
return contactName;
}
string ContactNode::GetPhoneNumber(){
return contactPhoneNum;
}
ContactNode* ContactNode::GetNext(){
return nextNodePtr;
}
void ContactNode::PrintContactNode(){
ContactNode *temp;
if(nextNodePtr!=NULL) {
cout<<"Contact Name:
"<<nextNodePtr->GetName()<<endl;
cout<<"Phone number:
"<<nextNodePtr->GetPhoneNumber()<<endl<<endl;
GetNext()->PrintContactNode();
}
}
Contacts.h:
#ifndef Contact_H
#define Contact_H
#include<string>
using namespace std;
class ContactNode{
public:
ContactNode();
ContactNode(string name, string phone);
void InsertAfter(ContactNode*);
string GetName();
string GetPhoneNumber();
ContactNode* GetNext();
void PrintContactNode();
private:
string contactName;
string contactPhoneNum;
ContactNode* nextNodePtr;
};
#endif
OUTPUT:

Hello I need some help with my CC+ project. My current project erasing the first two...
20.6 Lab: Contacts You will be building a linked list. Make sure to keep track of both the head and tail nodes (1) Create three files to submit. ContactNode.h-Class declaration ContactNode.cpp- Class definition main.cpp-main0 function (2) Build the ContactNode class per the following specifications Parameterized constructor. Parameters are name followed by phone number Public member functions InsertAfter0 (2 pts) GetName0 -Accessor(1 pt) GetPhoneNumber- Accessor (1 pt) GetNext0-Accessor (1 pt) PrintContactNode Private data members string contactName string contactPhoneNum ContactNode* nextNodePtr Ex....
Declare and define TtuStudentNode in TtuStudentNode.h and TtuStudentNode.cpp file. TtuStudentNode has its unique string variable "studentEmail" which contains email address. TtuStudentNode has its unique function member GetEmail() which returns the string variable "studentEmail". TtuStudentNode has its overriding "PrintContactNode()" which has the following definition. void TtuStudentNode::PrintContactNode() { cout << "Name: " << this->contactName << endl; cout << "Phone number: " << this->contactPhoneNum << endl; cout << "Email : " << this->studentEmail << endl; return; } ContactNode.h needs to have the function...
(In C) 8.12 LAB: Warm up: Contacts You will be building a linked list. Make sure to keep track of both the head and tail nodes. (1) Create three files to submit. ContactNode.h - Struct definition, including the data members and related function declarations ContactNode.c - Related function definitions main.c - main() function (2) Build the ContactNode struct per the following specifications: Data members char contactName[50] char contactPhoneNum[50] struct ContactNode* nextNodePtr Related functions CreateContactNode() (2 pt) InsertContactAfter() (2 pts) Insert...
I need to get this two last parts of my project done by tonight. If you see something wrong with the current code feel free to fix it. Thank you! Project 3 Description In this project, use project 1 and 2 as a starting point and complete the following tasks. Create a C++ project for a daycare. In this project, create a class called child which is defined as follows: private members: string First name string Last name integer Child...
Hello, I have some errors in my C++ code when I try to debug it.
I tried to follow the requirements stated below:
Code:
// Linked.h
#ifndef INTLINKEDQUEUE
#define INTLINKEDQUEUE
#include <iostream>
usingnamespace std;
class IntLinkedQueue
{
private: struct Node {
int data;
Node *next;
};
Node *front; // -> first item
Node *rear; // -> last item
Node *p; // traversal position
Node *pp ; // previous position
int size; // number of elements in the queue
public:
IntLinkedQueue();...
In need of some help with a LCR C++ game. The code will run, but I need it to cycle through the turns automatically so that the only input from the user is the number of players. It's also showing the winner as the person with 0 chips which is incorrect and I can't figure out why. Any help is greatly appreciated as this is already late. Game rules: Develop a program that follows the rules of Left Center Right...
C++: Need help debugging my code
I am writing this and using some other examples as reference code
while rewriting it with my own understanding of the material but am
having trouble making it finally compile. Below is a picture of the
error messages.
//main.cpp
//Semester Project
//Created by J---on 5/6/2019
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
void instructions(); //displays program details and
instructions
void openFile();
void takeInput(int*);
void switchBoard(int*);
struct price
{...