Question

C++ with Pseudocode in the beginning This assignment will require you to write a program that...

C++ with Pseudocode in the beginning

This assignment will require you to write a program that will create an array of 10 string objects. The array will be initialized with the strings which contain the person’s name and phone number in one string. The following is an example of test data:

“Renee Javens, 678-1223”,

“Joe Looney, 586-0097”,

“Geri Palmer, 223-8787”,

“Lynn Presnell, 887-1212”,

“Bill Wolfe, 223-8878”,

“Sam Wiggins, 486-0998”,

“Bob Kain, 586-8712”,

“Tim Haynes, 586-7676”,

“John Johnson, 223-9037”,

“Jean James, 678-4939”,

“Ron Palmer, 486-2783”

The program will prompt the user for the name or part of a name to search for. For example, the user may type in “Joe”, and the program should then display “Joe Looney, 586-0097.” If the user enters “Pal” then the program should have two outputs from the above list.

The program should make use of the string object methods to find the matches. The array should be created in main and use a method to search the array to find the name(s) in the array. If a match is not found then it should display a message indicating there is no match. The method must be passed the array of data.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Output:

Activities y Visual Studio Code 168% - Sun Mar 22, 01:02 strsearch.cpp - HomeworkLib - Visual Studio Code - . x File Edit Selection

CODE:

 #include <iostream> #include<string> using namespace std; int main() { //array of strings... string names[11] = { "Renee Javens, 678-1223", "Joe Looney, 586-0097", "Geri Palmer, 223-8787", "Lynn Presnell, 887-1212", "Bill Wolfe, 223-8878", "Sam Wiggins, 486-0998", "Bob Kain, 586-8712", "Tim Haynes, 586-7676", "John Johnson, 223-9037", "Jean James, 678-4939", "Ron Palmer, 486-2783" }; //name will be entered by the user string name; //ask the user to enter name to search cout<<"Enter the name that you want to search\n"; cin>>name; //for every item in names[] for(int i=0;i<11;i++) { //string::npos is a type of size_t variable, //it will be greatest possible number if find() is not not successful //so if names[i].find(name) is not string::npos, then name is found in names[i] if(names[i].find(name)!=string::npos) { cout<<names[i]<<endl; } } return 0; }
Add a comment
Know the answer?
Add Answer to:
C++ with Pseudocode in the beginning This assignment will require you to write a program that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that has an array of at most 50 strings that hold people’s names...

    Write a program that has an array of at most 50 strings that hold people’s names and phone numbers. You can assume each string’s length is no more than 40. You may make up your own strings, or use the following: "Becky Warren, 555-1223" "Joe Looney, 555-0097" "Geri Palmer, 555-8787" "Lynn Presnell, 555-1212" "Holly Gaddis, 555-8878" "Sam Wiggins, 555-0998" "Bob Kain, 555-8712" "Tim Haynes, 555-7676" "Warren Gaddis, 555-9037" "Jean James, 555-4939" "Ron Palmer, 555-2783" The program should ask the user...

  • Write and test a function in C++ that uses the binary search algorithm to search an...

    Write and test a function in C++ that uses the binary search algorithm to search an array of sorted strings – use a do..while loop to allow user to perform multiple searches w/o terminating the program – see sample output below. Use this name array: string names[SIZE] = { "Collins, Bill", "Smith, Bart", "Allen, Jim",         "Griffin, Jim", "Stamey, Marty", "Rose, Geri", "Taylor, Terri",         "Johnson, Jill", "Allison, Jeff", "Looney, Joe", "Wolfe, Bill",         "James, Jean", "Weaver, Jim", "Pore, Bob",...

  • Write a main function that declares the names, marks, number of elements as well as the...

    Write a main function that declares the names, marks, number of elements as well as the value to be searched for and the index of the returned function calls. Read and display the contents of names and marks. Ask the user for a name and using the linear search return the index to the user. If -1 is returned then the name is not in the file. Otherwise write out the name and mark for that student. Sort the arrays...

  • PROGRAM DESCRIPTION: In this assignment, you will be creating a memory matching game in C++. In t...

    c++ PROGRAM DESCRIPTION: In this assignment, you will be creating a memory matching game in C++. In this game, the user will need to match up the pairs symbols A,B,C,D,E on a 4x4 array. For example, the array could be initialized like the following: In this case, X represents an empty slot. The goal is for the user to match the A to the A, the B to the B, etc, until all pairs are matched up to win the...

  • Write the program in C The following statistics for cities of the Vege country are stored...

    Write the program in C The following statistics for cities of the Vege country are stored in a file: Name: a string of characters less than 15 characters long. Population: an integer value. Area: square miles of type double Write a program that: asks and gets the name of the input file from the user. Read the contents of the file into an array length 10 of structures -ask the user for the name of a city (less than 15...

  • Write a C++ program that simulates a lottery game. Your program should use functions and arrays....

    Write a C++ program that simulates a lottery game. Your program should use functions and arrays. Define two global constants: - ARRAY_SIZE that stores the number of drawn numbers (for example 5) -MAX_RANGE that stores the highest value of the numbers ( for example 9 ) The program will use an array of five integers named lottery, and should generate a random number in the range of 0 through 9 for each element of the array. The user should enter...

  • Please use pseudocode for this response, any additional advice for making this as easy to understand...

    Please use pseudocode for this response, any additional advice for making this as easy to understand as possible is greatly appreciated. Problem Statement Assume the Scores array is parallel to the Players array (both arrays are below). Scores array Scores[0] = 198 Scores[1] = 486 Scores[2] = 651 Scores[3] = 185 Scores[4] = 216 Scores[5] = 912 Scores[6] = 173 Scores[7] = 319 Scores[8] = 846 Scores[9] = 989 Players Array Players[0] = "Joe" Players[1] = "Ann" Players[2] = "Marty"...

  • This lab is to give you more experience with C++ Searching and Sorting Arrays Given a...

    This lab is to give you more experience with C++ Searching and Sorting Arrays Given a file with data for names and marks you will read them into two arrays You will then display the data, do a linear search and report if found, sort the data, do a binary search. Be sure to test for found and not found in your main program. Read Data Write a function that reads in data from a file using the prototype below....

  • Write a program (C++) that shows Game sales. The program should use a structure to store...

    Write a program (C++) that shows Game sales. The program should use a structure to store the following data about the Game sale: Game company Type of Game (Action, Adventure, Sports etc.) Year of Sale Sale Price The program should use an array of at least 3 structures (3 variables of the same structure). It should let the user enter data into the array, change the contents of any element and display the data stored in the array. The program...

  • In Java. Write a GUI contact list application. The program should allow you to input names...

    In Java. Write a GUI contact list application. The program should allow you to input names and phone numbers. You should also be able to input a name and have it display the previously entered phone number. The GUI should look something like the following, although you are welcome to format it in any way that works. This should be a GUI application with a JFrame. The program should contain two arrays of Strings. One array will contain a list...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT