Modify the sample code to prompt the user for a name. Have the program search the existing list for the entered name. If the name is in the list, display the corresponding phone number; otherwise display this message, The name is not in the current phone directory. #include #include using namespace std; const int MAXNAME = 30; const int MAXTEL = 15; struct Tele_typ { char name[MAXNAME]; char phone_no[MAXTEL]; Tele_typ* nextaddr; }; void display(Tele_typ*); int main() { Tele_typ t1 = { " Cage, Mark", "(555) 898-2392" }; Tele_typ t2 = { " Dolan, Nick", "(555) 682-3104" }; Tele_typ t3 = { " Lennon, John", "(555) 718-4581" }; Tele_typ* first; first = &t1; t1.nextaddr = &t2; t2.nextaddr = &t3; t3.nextaddr = NULL; display(first); return 0; } void display(Tele_typ * contents) // of type Tele_typ { while (contents != NULL) { cout.setf(ios::left); cout.width(25); cout << '\n' << contents->name; cout.width(20); cout << contents->phone_no; contents = contents->nextaddr; }cout << endl; return; }

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

Modify the sample code to prompt the user for a name. Have the
program search the existing list for the entered name. If the
name is in the list, display the corresponding phone number;
otherwise display this message,
The name is not in the current phone directory.

#include<iostream>
#include<iomanip>

using namespace std;
const int MAXNAME = 30;
const int MAXTEL = 15;
struct Tele_typ
{
char name[MAXNAME];
char phone_no[MAXTEL];
Tele_typ* nextaddr;
};
void display(Tele_typ*);
int main()
{
Tele_typ t1 = { " Cage, Mark", "(555) 898-2392" };
Tele_typ t2 = { " Dolan, Nick", "(555) 682-3104" };
Tele_typ t3 = { " Lennon, John", "(555) 718-4581" };
Tele_typ* first;

first = &t1;
t1.nextaddr = &t2;
t2.nextaddr = &t3;
t3.nextaddr = NULL;
display(first);
return 0;
}
void display(Tele_typ * contents)

// of type Tele_typ

{
while (contents != NULL)
{
cout.setf(ios::left);
cout.width(25); cout << '\n' << contents->name;
cout.width(20); cout << contents->phone_no;
contents = contents->nextaddr;
}cout << endl;

return;
}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
List
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.
Similar questions
  • SEE MORE QUESTIONS
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