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
List the data types that are allowed for SQL attributes.
nalin [4]

Answer:

Explanation:

In the SQL database manipulation coding language, there are a variety of different available data types to use. These data types are the following.

  • Numeric
  • Date/Time
  • Character/String
  • Unicode Character/String
  • Binary
  • 3rd Party / Miscellaneous

Each of these data types has a wide range of subcategories (data types as well) that each handle different variables in a coding sequence. These subcategories can be all seen in the attached picture below.

6 0
3 years ago
What is a perfect hashing function?
antiseptic1488 [7]

Answer:

First we understand what is hash function.A hash function is mostly used in Hashmaps. It maps different keys to a set of values.There may occur a case when we have same key but different values.This case is called collision.So we have to use different collision handling techniques that are open addressing and separate chaining.

A perfect hash function maps key-value pair such that there are no collisions.

3 0
2 years ago
Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending whe
Nana76 [90]

<u>Answer:</u>

<em>using System; </em>

<em>public class Program </em>

<em>{ </em>

<em> public static void Main() </em>

<em> { </em>

<em> String input ; </em>

<em> while(true) </em>

<em> { </em>

<em>  input = Console.ReadLine(); </em>

<em>  if(input.Equals(""quit"")) </em>

<em>  break; </em>

<em>  Reverse_String(input); </em>

<em> } </em>

<em> return; </em>

<em> } </em>

<em>static void Reverse_String(string input_text) </em>

<em>{ </em>

<em>    char[] text = input_text.ToCharArray(); </em>

<em>    Array.Reverse(text); </em>

<em>    Console.WriteLine(text); </em>

<em>} </em>

<u>Explanation:</u>

<em>In the above program a separate function is written to reverse the string.</em>

This method takes the string as an argument and place it in a array and then use the built-in function reverse and print the reversed string in the console.

<em>In the main(), the input is obtained from the console and it is passed to the reversestring(). </em>

7 0
3 years ago
Read 2 more answers
What is the correct process for selecting an entire row in a spreadsheet?
Valentin [98]
A. Click on any cell in the row
7 0
3 years ago
g Assume that this program is run on a processor with data cache of size big enough that the entire array arr can fit in the cac
Dimas [21]

Answer:

A. 2

Explanation:

The food function in the C source code uses two for loop statements to fill and array of size 100 with 100 values ranging from 1 to 100 and the second to get the total sum to the values in the array. With this, two program paths are created.

7 0
2 years ago
Other questions:
  • Which of the following is an example of a problem that could be attributed to poor ergonomics?
    10·1 answer
  • 2. a. Write pseudocode for a divide-and-conquer algorithm for finding valuesof both the largest and smallest elements in an arra
    11·1 answer
  • Describe Network in terms of the classroom computer lab
    14·1 answer
  • Which question about whale sharks is nonscientific?
    11·2 answers
  • Is it possible to have a deadlock involving only oneprocess? Explain your answer.
    11·1 answer
  • Can anyone please help me to solve this question?
    10·1 answer
  • While using a web-based order form, an attacker enters an unusually large value in the Quantity field. The value he or she enter
    15·1 answer
  • Question #3
    15·2 answers
  • How many domains are there in the classification system?
    13·1 answer
  • Class ____________ allow you to create one version of a class, without having to replicate code to handle multiple data types.
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!