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]
3 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]3 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
8.7 Code Practice: Question 1 edhesive
Ronch [10]

Answer:

here got from a friend

Explanation:

w = ["Algorithm", "Logic", "Filter", "Software", "Network", "Parameters", "Analyze", "Algorithm", "Functionality", "Viruses"]

for i in range (len(w)):

   print(w[i].upper())

5 0
3 years ago
Which of the following is not a valid variable name? 2 myInt 2. return 3. myInteger 4. total3
Reptile [31]

Answer:

Correct answer is option (2) that is "return".

Explanation:

In any programming language, a variable name can be made up of letters (lower and upper case) and digits. we can also use "_" underscore character for declaring the variables but we cannot use any special character like “$”.We cannot use digits in the beginning of variables name. And we also cannot use reserved keywords of the language like "new","return","while" etc. There should not be space between the variable names. Options 1, 3 and 4 are not violating any of these properties. But in option (2), "return" is a reserved keyword. That is why it is not a valid variable name.

Some example of valid variables name:

foo

BAZ

Bar

_foo42

foo_bar

Some example of invalid variables name:

$foo    ($ not allowed)

while   ( keywords )

2foo    (started with digit)

my foo  (spaces )

5 0
3 years ago
Tick the correct option.
sashaice [31]

Answer:

print

plz follow me

.........

4 0
2 years ago
Read 2 more answers
You should structure the blank first before you search for a relevant picture
serious [3.7K]

Answer: true

Explanation:

3 0
3 years ago
Read 2 more answers
A _____ is a prewritten formula that is built into Excel.
Fittoniya [83]
The answer is a function.
In Microsoft Office Excel, a function refers to the pre-written formula that is built. There are a lot of functions in Microsoft Office Excel like the arithmetic functions such as sum or total, difference, and an average of numbers. In Excel, these functions are defined using Visual Basic.
3 0
4 years ago
Other questions:
  • Write a Raptor program that will generate a random number between 1 and 100; do not display the randomly generated number. Let t
    8·2 answers
  • You can be sentenced to up to 180 days in jail for driving with a license that was suspended for _________ .
    15·1 answer
  • (BRAINLIEST QUESTION) What are some challenges that will need to be overcome in order for the Internet of Vehicles to become a r
    13·1 answer
  • 25 POINTS! PLEASE ANSWER! Karrie would like to draw attention to some short statements in her document. What is the best way to
    6·2 answers
  • Which fact does lean green eco machines present to show that electric cars are not perfect
    13·2 answers
  • Assume you have a variable, budget, that is associated with a positive integer. Assume you have another variable, shopping_list,
    11·1 answer
  • How is a digital representation of analog data a form of abstraction? Why is the quality of the photo, music, etc better when mo
    11·1 answer
  • Mingji is working to transfer photos from her digital camera to her computer. While
    11·1 answer
  • Blockchain is often associated with Bitcoin and the financial services industry. However, it is applicable to almost every indus
    13·1 answer
  • What's a big question or problem in the tech field you'd like to solve and why?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!