Create a program of several prototypes for functions, C/C++ Programming

Assignment Help:

In this assignment the main has been written for you in the file phone_book_main.cpp. You will also notice that a class called Person has been declared as having several prototypes for functions. You will define all of these in a file called hw7.cpp.

How the program is supposed to function.

When you first run the program it fills a vector called phone_book with some default values and then outputs the contents of the vector. After this it displays a "menu" where the user can input a number to run a function that will manipulate the phone_book vector in some manner. 1) Add people to the phone book.2) Erase a person from the phone book.3) Sort the phone book.4) Shuffle the phone book.5) Reverse the phone book.6) Print the phone book.7) Look up a person in the phone book.8) Quit.

Add people to the phone book.

Selecting this option runs a function: void add_people(vector&phone_book); This function will ask a user to enter a name or Q to quit. Next it will ask for a phone number. Then the function constructs a person object using the data the user gave and add it to the end of the phone book. Then the user is again told to enter a name or Q to quit and so on.

Erase a person from the phone book

When a user selects this option, it first asks the user for a name (This is done in main so you are not responsible for it) then runs a function: void erase(vector&phone_book, string name); This function finds the entry in the phone book with the corresponding name and then erases it.

Sort the phone book.

Selecting this option runs a function: void sort(vector&phone_book); This function sorts the vector phone_book in lexicographical order using the name entry of the Person class.

Shuffle the phone book.

Selecting this option runs the function: void shuffle(vector&phonebook); This function works much like the shuffle function discussed in class.

Reverse the phone book.

Selecting this option runs the function: void reverse(vector&phonebook); This function reverses the vector.

Print the phone book.

Selecting this option runs the function: void print(vector&phone_book); This function outputs the contents of the vector.

Look up a person in the phone book.

When a user selects this option it first asks the user for a name (This is done in main so you are not responsible for it) then runs a function: int lookup(const vector&phonebook, string name); This function returns the phone number of the Person with the matching name. Once your function returns the phone number to the main it is then outputted to screen. (This is done in main and you are not responsible for it.)

Other instructions

You need to be careful with indices. If someone searches for a person in your phone book who is not there your program should not crash! Your function lookup should return -1, for example, when the user wants to find a phone number for a Person who is not in the phone book.

Helpful hints

  • You are only creating file hw7.cpp and using it in combination with the files phonebook.h and phone_book_main.cpp already provided for you.
  • You CANNOT change the files phonebook.h and phone_book_main.cpp!
  • Your first step should be to get a program that compiles without writing the details of the functions quite yet.
  • You will not be able to compile until all the functions definitions have been written. Write empty function definitions with just return statements where needed.
  • You should write the functions but leave everything inside { } empty except possibly a return statement where needed.
  • Once the program compiles, start filling in the functions inside hw7.cpp
  • You may write helper functions like swap when needed.

Related Discussions:- Create a program of several prototypes for functions

Padovan string, #question:-program to counts tha no of occurances of the st...

#question:-program to counts tha no of occurances of the string in the nth padovan string

If else, A small shop sells 280 different items. Every item is identified b...

A small shop sells 280 different items. Every item is identified by a 3 - digit code. All items which start with a zero (0) are cards, all items which start with a one (1) are swee

What if one forget the [] when deleteing array allocated , What if one forg...

What if one forget the [] when deleteing array allocated through new T[n]? A: All life comes to a disastrous end. It is the programmer's responsibility not the compiler's to

What are the different types of endless loops, What are the different types...

What are the different types of endless loops? An endless loop can be of two types: i.) A loop that is intentionally designed to go round and round until the condition withi

Define difference among delete and delete[]?, when you allocate memory with...

when you allocate memory with new[], you ought to free the memory via delete[]. While you allocate memory along 'new', then use 'delete' with no the brackets. You employ new[] to a

Explain the process of using the constructor, Using the Constructor The...

Using the Constructor There are basically three ways of creating and initializing the object. The first way to call the constructor is explicitly as :

Program of three numbers arguments and returns the sum , Define a procedure...

Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.

Assignment, Hi, Can i get a quote for my Programming assignment

Hi, Can i get a quote for my Programming assignment

What is the difference among malloc/free and new/delete?, What is the diffe...

What is the difference among malloc/free and new/delete? A: Malloc/free do not know about destructors and constructors. New & delete create and destroy objects, whereas malloc &

C program to create a file student.dat, Program is to create a file student...

Program is to create a file student.dat: Program is to create a file student.dat which contains all name, roll_no,marks(5 sub) and percentage   class student    {

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd