Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 7, Problem 4P

The following code creates a small phone book. An array is used to store a list of names and another array is used to störe the phone numbers that go with each name. For example. Michael Myers’ phone number is 333-8000 and Ash Williams’ phone number is 333-2323. Write the function lookupName so the code properly looks up and returns the phone number for the input target name.

  int main ()

  {

  using namespace std;

  string names[] = {“Michael Myers”,

  “Ash Williams”,

     “Jack Torrance”,

     “Freddy Krueger”};

  string phoneNumbers[] = {“333–8000”, “333–2323”,

  “333–6150”, “339–7570”};

  string targetName, targetPhone;

  char c;

  do

  {

  cout << “Enter a name to find the ”

  << “corresponding phone number.”

  << endl;

  getline(cin, targetName);

  targetPhone = lookupName(targetName,

  names, phoneNumbers, 4);

  if (targetPhone.length() > 0)

  cout << “The number is: “

  << targetPhone << endl;

  else

  cout << “Name not found. ”

  << endl;

  cout << “Look up another name? (y/n)”

  << endl;

  cin > c;

  cin.ignore();

  } while (c == ‘y’);

  return 0;

  }

Blurred answer
Students have asked these similar questions
(C language) Write a function intersect() that takes five arguments: an array of integers, number of elements in this array, a second array of integers, number of elements in the second array, a third array as parameters; finds the numbers in the first array that also exist in the second array and places these numbers into the third array;  returns the number of matching values stored in array-3. Prototype:       int intersect(int ar1[], int n1, int ar2[], int n2, int ar3[]) ps: please do not copy paste from chegg or anywhere else. write a unique code.
5. Write a function which will find the average of all elements of an array of integers. Pass an array and a dimension (the number of elements), and return the value of the average as a float ( the return value). Test this function in the main program with the array: 5, 7, 3, 5, 6, 4.
Write a function which takes an array of strings (array size is 5); then finds the number of vowels and consonants in each string. The function should create and print a 5x2 array to store this information against each string.For example if:Array:{“hello” “i”, “love”, “this”, “course”}2D array created by function:[[2,3], [1,0], [2,2], [1,3],[3,3]] write code in c++

Chapter 7 Solutions

Problem Solving with C++ (10th Edition)

Ch. 7.2 - Consider the following function definition: void...Ch. 7.2 - Prob. 12STECh. 7.2 - Write a function definition for a function called...Ch. 7.2 - Consider the following function definition: void...Ch. 7.2 - Insert const before any of the following array...Ch. 7.2 - Write a function named outOfOrder that takes as...Ch. 7.3 - Write a program that will read up to ten...Ch. 7.3 - Write a program that will read up to ten letters...Ch. 7.3 - Following is the declaration for an alternative...Ch. 7.4 - Prob. 20STECh. 7.4 - Write code that will fill the array a (declared...Ch. 7.4 - Prob. 22STECh. 7 - Write a function named firstLast2 that takes as...Ch. 7 - Write a function named countNum2s that takes as...Ch. 7 - Write a function named swapFrontBack that takes as...Ch. 7 - The following code creates a small phone book. An...Ch. 7 - There are three versions of this project. Version...Ch. 7 - Hexadecimal numerals are integers written in base...Ch. 7 - Solution to Programming Project 7.3 Write a...Ch. 7 - Prob. 4PPCh. 7 - Write a program that reads in a list of integers...Ch. 7 - Prob. 6PPCh. 7 - An array can be used to store large integers one...Ch. 7 - Write a program that will read a line of text and...Ch. 7 - Write a program to score five-card poker hands...Ch. 7 - Write a program that will allow two users to play...Ch. 7 - Write a program to assign passengers seats in an...Ch. 7 - Prob. 12PPCh. 7 - The mathematician John Horton Conway invented the...Ch. 7 - Redo (or do for the first time) Programming...Ch. 7 - Redo (or do for the first time) Programming...Ch. 7 - A common memory matching game played by young...Ch. 7 - Your swim school has two swimming instructors,...Ch. 7 - Your swim school has two swimming instructors,...Ch. 7 - Prob. 19PPCh. 7 - The Social Security Administration maintains an...

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
What are the advantages and disadvantages of implicit declarations?

Concepts of Programming Languages (11th Edition)

Write the example program in Figure 2.7 in actual bit patterns.

Computer Science: An Overview (13th Edition) (What's New in Computer Science)

What is the purpose of the Application classs abstract start method?

Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)

Knowledge Booster
Background pattern image
Computer Science
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
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
1.1 Arrays in Data Structure | Declaration, Initialization, Memory representation; Author: Jenny's lectures CS/IT NET&JRF;https://www.youtube.com/watch?v=AT14lCXuMKI;License: Standard YouTube License, CC-BY
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License