1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kolbaska11 [484]
4 years ago
12

Write a program that has an array of at least 50 string objects that hold people’s names and phone numbers. The program then rea

ds lines of text from a file named phonebook into the array. The program should ask the user to enter a name or partial name to search for in the array. All entries in the array that match the string entered should be displayed-- thus there may be more than one entry displayed. The program prints the message "Enter a name or partial name to search for: " and then after the user enters some input and hits return, the program skips a line, and prints the heading: "Here are the results of the search:", followed by each matched string in the array on a line by itself. Input Validation: None
Computers and Technology
1 answer:
Readme [11.4K]4 years ago
8 0

Answer:

See explaination

Explanation:

#include <iostream>

#include <fstream>

#include <string>

using namespace std;

int main()

{

const int SIZE = 50;

string phoneDirectory[SIZE];

int size=0;

string name; //name to look for

ifstream inFile;

inFile.open("phonebook");

while (!inFile.fail()) {

getline(inFile,phoneDirectory[size]);

size++;

}

inFile.close();

// Get a name or partial name to search for.

cout << "Enter a name or partial name to search for: ";

getline(cin, name);

cout << "\nHere are the results of the search: " << endl;

int numberEntriesFound = 0;

for (int k = 0; k < size; k++)

{

if (phoneDirectory[k].find(name.data(), 0) < phoneDirectory[k].length())

{

numberEntriesFound ++;

cout << phoneDirectory[k] << endl;

}

}

if (numberEntriesFound == 0)

cout << "\nNo Entries were found for " << name;

return 0;

}

You might be interested in
In popular usage and in the media, the term ________ often describes someone who breaks into a computer system without authoriza
ch4aika [34]
The answer here is hacker
6 0
3 years ago
Which functions are available in a Word table? Check all that apply.
dexar [7]
All of them are available
3 0
3 years ago
What are the cons of using keyboard shortcuts?
Yanka [14]

Answer:

Mistakes can easily occur while using them.

4 0
3 years ago
One group of students did an experiment to study the movement of ocean water. The steps of the experiment are listed below.
dsp73

The lamp and the ice bag were at the same place.  
Sounds like the experiment was intended to show on a small scale ocean currents from the poles to the equator and back to the poles. The bag of ice would simulate the cold at the poles while the lamp would simulate the heat provided by the sun near the equator. With that in mind, let's look at the possible flaws and see what is likely.  
Not enough ink was added.
 * If you can see the ink, then there's enough ink. So this isn't the correct choice.  
Not enough water was taken.
 * Possibility there wasn't enough volume of water to setup a current, but not too likely since the baking dish was filled. So let's look further. 
 The dish was too small for the experiment.
 * Same as above. It might be this, but there's something more likely. 
 The lamp and the ice bag were at the same place.
 * This sounds like a winner. In the real world, the poles are cold and the equator gets more sunlight. So there's a temperature gradient. In the described setup, both the heat sink (the bag of ice) and the heat source (the lamp) were at the same location.
5 0
3 years ago
Assume a program requires the execution of 50 x 106 FP instructions, 110 x 106 INT instructions, 80 x 106 L/S instructions, and
Molodets [167]

Explanation:

FP - 50 \times 10^6

CPI - 1

INT -110 \times 10^6,

CPI - 1

I/S - 80 \times 10^6 ,

CPI - 4

Branch - 16 \times 10^6

CPI - 2

Clock Speed - 2 \times 10^9

Time(old) =\frac{50 x 10^6 + 110 x 10^6 + 4 x ( 80 x 10^6) + 2 x (16 x 10^ 6)}{2 x 10^9}

Time(old) = 256 \times 10^ {-3}

Time(new) =  \frac{256 \times 10^{-3}}{2}

                = 128 \times 10^{-3}

                =\frac{CPI(new) x [50 x 10^6 + 110 x 10^6 + 4 x ( 80 x 10^6) + 2 x (16 x 10^ 6)]}{2 x 10^9}

                =  128 \times 10^{-3}

CPI(new) = \frac{-206}{50}

               = -4.12

3 0
3 years ago
Other questions:
  • business owners and managers may first balk at the idea of mobile officer workers because there may appear to be a lack of ___ w
    9·1 answer
  • Within a single program, __________________ allows multiple parts, or threads, to run simultaneously.
    15·1 answer
  • Grading on the curve is a method of grading that is based on the belief that letter grades for any given class should be distrib
    8·1 answer
  • The intuitive interface designed by alan kay is called a ________.
    11·1 answer
  • Consider the conditions and intentions behind the creation of the internet—that it was initially created as a tool for academics
    12·1 answer
  • Is the ability to choose the start and finish times, but they must complete a full day’s work
    8·1 answer
  • What is the difference between MAC address and IP address?<br> Thanks in advance
    6·1 answer
  • Create the HTML code for this
    14·1 answer
  • I cant tell if tubbo is a bee or a goat <br>or could he be human in the smp
    12·1 answer
  • What component of a change management program includes final testing that the software functions properly
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!