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

  Create class templates for administrative employess

Create classes or class templates for the following: Administrative Employess are paid a salary, but they also receive a bonus at regular intervals during the year.

  Get input from command line file1 & file2

Check if file1 is the same as file2, if yes, printout error message

  Specific changes made for different countries-sites directed

Why were these specific changes made for different countries at whom the sites were directed? Is there anything else you would consider changing.

  Create a very abstract programming environment

Find these header files in the Visual Studio system and determine the smallest (i.e., most negative) and largest (i.e., most positive) values that can be represented as int, unsigned int, long, unsigned long, float and double.

  Program to print total balances forward and total withdrawal

At the end of report, print total balances forward, total deposits, total interest earned, total withdrawals and total final account balances.

  Enhance the web page the following elements

Ensure required fields First name, Last name are not blank.

  Pseudo code for recursive function to print prime numbers

Write in pseudo code the recursive function which receive 2 integers (a and b) and returns sum of all common prime dividers (1 is not prime).

  Create a class which holds account number

Create a class named Loan which holds the account number, name of account holder, amount borrowed, term, and interest rate. Include methods to set values for each data field.

  Write a program that will keep track of golf handicaps.

Write a program that will keep track of golf handicaps. To find a player's handicap, you will need to know the player's score, the course rating and the course slope.

  Designing the site links

Company needs to be able to schedule the time of day when the connections are available for replication. Replication should not occur during peak business hours. When designing the site links, which of the following options should you use?

  Write a perl program that asks a user for a motif

Write a Perl program that asks a user for a motif (like QDSV or MKPL) and returns a message saying whether the motif is found in the sequence or not - Write a program that calculates and prints

  Compare and contrast three scripting languages

For this project, students will compare and contrast three scripting languages, the approaches, and techniques used in each to facilitate interactive design

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