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
The geographic coordinate system is used to represent any location on Earth as a combination of latitude and longitude values. T
Pachacha [2.7K]

Answer:

Here is the script:  

function dd = functionDMS(dd)  

prompt= 'Enter angle in DD form ';

dd = input(prompt)

while (~checknum(dd))

if ~checknum(dd)

error('Enter valid input ');

end

dd = input(prompt)

end  

degrees = int(dd)

minutes = int(dd - degrees)

seconds = ( dd - degrees - minutes / 60 ) * 3600  

print degrees

print minutes

print seconds

print dd

Explanation:

The script prompts the user to enter an angle in decimal degree (DD) form. Next it stores that input in dd. The while loop condition checks that input is in valid form. If the input is not valid then it displays the message: Enter valid input. If the input is valid then the program converts the input dd into degrees, minutes and seconds form. In order to compute degrees the whole number part of input value dd is used. In order to compute the minutes, the value of degrees is subtracted from value of dd. The other way is to multiply remaining decimal by 60 and then use whole number part of the answer as minutes. In order to compute seconds subtract dd , degrees and minutes values and divide the answer by 60 and multiply the entire result with 3600. At the end the values of degrees minutes and seconds are printed. In MATLAB there is also a function used to convert decimal degrees to degrees minutes and seconds representation. This function is degrees2dms.

Another method to convert dd into dms is:

data = "Enter value of dd"

dd = input(data)

degrees = fix(dd);

minutes = dd - degrees;

seconds = (dd-degrees-minutes/60) *3600;

8 0
3 years ago
Im bored, any anime recommendations? i probably watched whatever youre gonna say
Alex777 [14]

Answer:

Hi..

Explanation:

i have seen a lot of anime shows XD hunter x hunter, dbz, black clover, 7 deadly sins

3 0
3 years ago
Read 2 more answers
Intellectual ______ is the legal term for ownership of intangible assets such as ideas, art, music, movies, and software.
SOVA2 [1]

Answer:

<u>Property</u>

Explanation:

Intellectual Property (IP) is the lawful protection of human idea/intellect by unauthorised users. These human intellects are intangible assets that have both moral and commercial value. They include ideas, art, music, movies, software e.t.c.

Common types of Intellectual property include

  • Copyrights
  • patents
  • Trade Marks
  • Trade Secrets
5 0
3 years ago
Read 2 more answers
Advantages of monolithic operating system? ​
Lyrx [107]

Advntage:

provides CPU scheduling, memory management, file management, and other operating system functions through system calls. The other one is that it is a single large process running entirely in a single address space.

Disadvantage: if anyone service fails it leads to an entire system failure

8 0
2 years ago
What does the poster exemplify?
zloy xaker [14]

Answer:

try D

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • A circuit has a resistance of 300 ohm and a current of 0.024 A. What is the voltage in the circuit?
    12·1 answer
  • A) What is the maximum value that can be represented as an unsigned n-bit binary integer?
    13·1 answer
  • Your program will demonstrate use of arrays, searching an array, using methods, passing parameters by reference, returning value
    13·1 answer
  • What kind of battery does a dji spark have?
    12·1 answer
  • Which format is best for the image below?
    12·1 answer
  • If you want to present slides to fellow students your coworkers which productivity software should you use to create them
    15·2 answers
  • Write a C++ program to count even and odd numbers in array. The array size is 50. The array elements will be entered by the user
    13·1 answer
  • Write a program that prompts the user to enter their name store this value in a variable called name Prompt the user for their c
    10·1 answer
  • The sequence of Figures shows a pattern. if the pattern repeats, how many triangles will the figure 5 have ?​
    7·1 answer
  • 20 POINTS! Which music making software is better? Ableton Live or Logic Pro? Name the advantages and disadvantages of each one!
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!