Declared as well as several prototypes for functions

Assignment Help Programming Languages
Reference no: EM131324380

Assignment

Goals

To learn about separate compilation, classes, and vector manipulation.

Your Assignment

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 well as several prototypes for functions. You will define all of these in a file called hw7.cpp. Note: When you download these files, right click on the link and then choose save link as (or save as. The exact wording depends on browser you are using.)

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<Person> &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.

Note: The function void add_people(vector &phone_book); requires both getline and cin to be used (getline for the name and cin for the number). The mixing of the two causes a technical problem with the new line character. There is an explanation in the book as well. Basically what happens is that after the cin there is still a newline left over and if we try to use a getline again to read a name, it gets tripped up by it. The solution is to read that newline into a dummy variable. So put another getline after the cin. cout << "Enter a phone number: "; cin >> number; string clear; getline(cin, clear); // after this the next getline will work!

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<Person> &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<Person> &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<Person> &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<Person> &phonebook); This function reverses the vector.

Print the phone book.

Selecting this option runs the function: void print(vector<Person> &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<Person> &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 all 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.

Once the program compiles, start filling in the functions inside hw7.cpp

You may write helper functions like swap when needed.

You may use the sort function defined in the algorith library.

Reference no: EM131324380

Questions Cloud

Quantities from only one component of financial statement : Find the monthly payment for a 35-year fixed-rate loan of $410,000 at 5.2% annual interest. Find the total sales price of a device that lists at $99.99 and is subject to a 3% sales tax. Which financial ratios use quantities from only one component of..
Identify the 5 ks of sikhism and explain which one intrigue : "5 Ks of Sikhism" Please respond to the following:Identify the 5 Ks of Sikhism, and explain which one intrigues you the most."After It's All Said and Done..." Please respond to the following:Explain what religion is, and give your opinion as to whe..
Involved in atp synthesis in mitochondria : Describe the order and linkage of the biochemical processes involved in ATP synthesis in mitochondria (glycolysis, TCA cycle,electron transport chain, proton pumping, ATP synthaseactivity)
Is there diminishing marginal productivity of practice yards : In terms of Ben's time in the big meet, what is his marginal productivity of the number of yards he practices? Is there diminishing marginal productivity of practice yards?
Declared as well as several prototypes for functions : PIC 10A: 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 well as several prototypes for functions.
Dominant alleles in humans and the genes occur : Freckles (F) and six fingers (S) are dominant alleles in humans and the genes occur on different chromosomes. If an FfSs male and an FfSs female have a WHOLE BUNCH of kids, Here are the expected ratios below.
Find the approximate risk free rate : Find the approximate risk-free rate ? What would happen in the options market if the price of an American call were less than the value Max(0, S0 - X)?
Describe the development of the airplane as a weapon of war : Describe the development of the airplane as a weapon of war. At a minimum include the RAF, Rotary Engines verses Inline Engines, artillery spotting by plane, the first air-to-air combat, the development of the interrupter gear by Roland Garros
What is the gain-loss per contract on the position : Suppose you purchase a call contract on a T-bond with an exercise price of 102 16/32 . The bond represents $100,000 of bond principal, and has a premium of $1,000. If the actual T-bond price falls to 100, what is the gain/loss per contract on the pos..

Reviews

Write a Review

Programming Languages Questions & Answers

  Develop a set of five insert statements

Develop a set of five INSERT statements to populate your table with information about each team - Create one constructor to create a book object and define getter functions as needed.

  Required to implement parties - pair programming

Required to implement Parties - The player should be in his/her own Party and there can be other Parties (both hostile and non-hostile) as well. You should implement the user stories

  Design program that allow player to play game of tic-tac-toe

Design a program that allows two players to play a game of tic-tac-toe. Use a two dimensional String array with three row and three columns as the game board.

  Create application program to declare two circles

Create an application program that declares two circles set radius of one manually but allow the other to use default value supplied by constructor then display each circles values.

  Develop the flow diagram

Develop the flow diagram of the information and any control elements needed to ensure proper access for the information.Submit a draft PowerPoint presentation with the following elements

  This laboratory gives practice in the creation and use of

this laboratory provides practice in the creation and use of basic and advanced sql queries involving more than one

  Include a pseudo code, flowcharts making complete solution

Your final document should contain a "hierarchy chart" of phases, flowcharts, pseudo code, data dictionary, and seven UML diagrams as developed in Visio and Word. Your document should also contain a paragraph narrative on how each diagram relates ..

  Write program to ask user to enter number between a range

Write down program which asks user to enter number between 1 and 100. Use input validation to make sure that a valid number is entered before continuing program.

  Program should prompt the user at the beginning

The program should prompt the user at the beginning for the number of different milk quantities to evaluate in this one run of the program.

  Write a windows application that gets names and e-mail

If the value of Write a Windows application that gets names and e-mail addresses from the user and displays a list of all of the user's contacts. Each time the user enters a new contact, he/she should able to see it added to a list of previously s..

  Create a user form that contains the usual ok and cancel

Create a user form that contains the usual OK and Cancel buttons

  Create new windows forms application named averagecalculator

Clearing the result. Write event handlers for the TextBoxes'TextChanged events. Write code to clear resultLabel after the user enters new input into any of the TextBoxes.

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