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
// New Function prototypes void showValues(const int *, int);  // display 10 numbers in a line from the array void fillArray(int *, int, int, int);     // fill out random numbers between low and high into the array bool searchValue(const int *, int, int);  // search value from the array void sortArray( int *, int);     //sort the array in an ascending order void swap(int *, int *);          //swap the values Modify the code below to create 50 random numbers instead of 10 and use the above new function protoypes. In the output, remove the display of the minimum, maximum and average from the array. Modify the showValues() function to display 10 numbers in a line from the array. [Part 2] Add the two functions to sort an array in an ascending order: void sortArray(int*, int); //ascending ordervoid swap(int*, int*); In the sortArray() function called the swap() function to swap the values from two elements in the array.   Code: #include <iostream>#include <iomanip>#include…
To receive an array argument, a function's parameter list must specify that the function expects to receive an array. The size of the array is not required between the array brackets. Select one: True False
Tasks: 1.Write a function myStrLen(char*) which returns the length of the parameter string without using strlen function. 2. Write a program that takes an array large enough to hold a user-defined number of test scores. Once all the scores are entered, the array should be passed to a function that sorts them in ascending order. Another function should be called that calculates the average score. The program should display the sorted list of scores and averages with appropriate headings. 3. Write a program to combine two string by using pointer without using any built-in function of strings.

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