Question

In: Computer Science

home / study / engineering / computer science / questions and answers / this is c....

home / study / engineering / computer science / questions and answers / this is c. create three files to submit. contacts.h ...

Question: This is C. Create three files to submit. Contacts....

Bookmark

This is C.

Create three files to submit.

Contacts.h - Struct definition, including the data members and related function declarations

Contacts.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 a new node after node

GetNextContact() (1 pt)

Return location pointed by nextNodePtr

PrintContactNode()


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-6610

Solutions

Expert Solution

/* header */

#include <iostream>
class Contracts
{
public:
   int totalcount;
   Contracts(void){totalcount =0;}
   ~Contracts(void);
   struct ContractNode
   {
       char contactName[50];
       char contactPhoneNum[50];
       struct ContactNode* nextNodePtr;
      
   };
   ContractNode cont[3];
   bool CreateContactNode() ;
   bool InsertContactAfter(int position);
   ContractNode GetNextContact();
   bool PrintContactNode();
  
};

/*cpp */

#include "StdAfx.h"
#include "Contracts.h"


Contracts::Contracts(void)
{
}


Contracts::~Contracts(void)
{
}

  
   bool Contracts::CreateContactNode() {
       for (int i =0; i <3 ;i++)
       {
           std::cout << "Enter Full name: ";
            std::cin.get( cont[i].contactName,50);
           std::cout << "Enter phone number: ";
            std::cin.get( cont[i].contactPhoneNum,50);
       }
   }
   bool Contracts::InsertContactAfter(int position){
       if ( position==4 )
       {
           std::cout << "Cannot inserte after 3 ";
       }
       else
       {

       for (int i =0; i <3 ;i++)
       {
           if(i==position)
           {
                   std::cout << "Enter Full name: ";
                   std::cin.get( cont[i].contactName,50);
                   std::cout << "Enter phone number: ";
                   std::cin.get( cont[i].contactPhoneNum,50);
           }
       }
       return true;
       }
       return false;
   }
   Contracts::ContractNode Contracts::GetNextContact(){
       switch(totalcount)
       {
           case 0:
               return cont[0];
           break;
           case 1:
               return cont[1];
           break;
           case 2:
               return cont[2];
               std::cout<< "This is last element"<<std::endl;

           break;

       };
       totalcount ++;
   }
        bool Contracts::PrintContactNode()
       {
           std::cout<< "CONTRACT LIST"<<std::endl;
           for (int i =0; i <3 ;i++)
           {
               std::cout << "Name: "<<cont[i].contactName <<std::endl;
               std::cout << "Name: "<< cont[i].contactPhoneNum<<std::endl;
           }
           return true;
       }

int main ()
{
   Contracts cont ;
   std::cout <<"Enter 3 Persons name and Phone number";
  
   cont.CreateContactNode();
   cont.PrintContactNode();

return 0;
}


Related Solutions

home / study / engineering / computer science / computer science questions and answers / create...
home / study / engineering / computer science / computer science questions and answers / create a new java file, containing this code public class datastatsuser { public static void ... Your question has been answered Let us know if you got a helpful answer. Rate this answer Question: Create a new Java file, containing this code public class DataStatsUser { public static void... Create a new Java file, containing this code public class DataStatsUser { public static void main...
home / study / engineering / computer science / computer science questions and answers / Modify...
home / study / engineering / computer science / computer science questions and answers / Modify StudentLinkedList Class By Adding The Following Methods:  PrintStudentList: Print ... Your question has expired and been refunded. We were unable to find a Chegg Expert to answer your question. Question: Modify StudentLinkedList class by adding the following methods:  printStudentList: print by call... Modify StudentLinkedList class by adding the following methods:  printStudentList: print by calling and printing “toString” of every object in...
home / study / engineering / computer science / computer science questions and answers / 2....
home / study / engineering / computer science / computer science questions and answers / 2. design an er-diagram for a bank that implements the following requirements. the database ... Question: 2. Design an ER-diagram for a bank that implements the following requirements. The database you d... 2. Design an ER-diagram for a bank that implements the following requirements. The database you design should store information about customers, accounts, branches and employees • Customer: Customers are identified by their SSN....
home / study / engineering / computer science / computer science questions and answers / write...
home / study / engineering / computer science / computer science questions and answers / write a program that in c++: 1.prompts the user to enter a positive integer, think of this ... Question: Write a program that in C++: 1.Prompts the user to enter a positive integer, think of this intege... Write a program that in C++: 1.Prompts the user to enter a positive integer, think of this integer as representing a specific number of pennies. 2. The program...
The questions read as follows: home / study / engineering / computer science / computer science...
The questions read as follows: home / study / engineering / computer science / computer science questions and answers / Course Grades Java Class In A Course, A Teacher Gives The Following Tests And Assignments: ... Question: Course grades java class In a course, a teacher gives the following tests and assignments: A lab ... course grades java class In a course, a teacher gives the following tests and assignments: A lab activity that is observed by the teacher and...
home / study / science / nursing / nursing questions and answers / This Is A...
home / study / science / nursing / nursing questions and answers / This Is A Theoretical Case Taken From VHA Intensive Ethics Advisory Committee Training, 1998, ... Your question has been posted. We'll notify you when a Chegg Expert has answered. Post another question. Next time just snap a photo of your problem. No typing, no scanning, no explanation required. Get Chegg Study App Question: This is a theoretical case taken from VHA Intensive Ethics Advisory Committee Training, 1998,...
home / study / science / nursing / nursing questions and answers / you are a...
home / study / science / nursing / nursing questions and answers / you are a public health researcher. you have been asked to identify a vaccine-preventable disease. ... Question: You are a public health researcher. You have been asked to identify a vaccine-preventable disease... You are a public health researcher. You have been asked to identify a vaccine-preventable disease. Your research design should focus on determining why health care workers are not receiving the vaccination for your selected vaccine-preventable...
home / study / science / biology / questions and answers / which of the following...
home / study / science / biology / questions and answers / which of the following best explains why atp is ... Question: Which of the following BEST explains why ATP is a ... Save Which of the following BEST explains why ATP is a positive regulator of aspartate transcarbamoylase (ATCase)? A. Aspartate is only available when ATP levels are high. B. ATP levels correspond to CTP levels, thus when both ATP and CTP are high, ATCase is active. C....
home / study / science / physics / physics questions and answers / this is my...
home / study / science / physics / physics questions and answers / this is my second time posting this: question: i have been working on this and i have done ... Question: This is my second time posting this:   Question: I have been working on this and I have... This is my second time posting this:   Question: I have been working on this and I have done it. But I am not sure what velocity versus time plot,... I...
home / study / science / nursing / nursing questions and answers / case study joshua...
home / study / science / nursing / nursing questions and answers / case study joshua thomson is an active 13-year-old who was riding his bike with friends when ... Question: Case Study Joshua Thomson is an active 13-year-old who was riding his bike with friends when he f... Case Study Joshua Thomson is an active 13-year-old who was riding his bike with friends when he fell while attempting to jump over a ditch. His friends helped him home, and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT