Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C++, Write a program that keeps track of a speakers' bureau. Name the structure SpeakerBureau. The program should use a structure to store the

Using C++,

Write a program that keeps track of a speakers' bureau. Name the structure SpeakerBureau. The program should use a structure to store the following data about a speaker:

Name (string, not c-string, the name may contain a space to separate first name and last name)

Telephone number (string, with - inside. The format should be 3 digits dash 4 digits)

Speaking topic (string, the topic may contain space)

Fee required (double, the number should be more than 0)

Your program should create a structure and have the following organization and menu choices. Use an inside loop to display all names stored, and an outside loop to allow the user to repeatedly choose from the following menu choices:

1) enter a speaker [ask user for an index number and allow entry of all data]

2) view a speakers info [ask user for an index number and display all data on that speaker]

3) display a count of how many speakers are in the list

4) quit

Functions:

To start with, you need the following variables in main:

int choice;

int size = 20;

SpeakBureau * speakers;

speakers = new SpeakBureau[size]; // make sure to free the memory when finished

void initializeValue(SpeakBureau * speakers, int size)

This function will initialize all string member variables to be - and numerical member variables to be 0

string getName()

This function will take users input as the speakers name. Users name should contain a space in the middle (not the first character or last character), Users name should also begin with an upper case letter

int getChoice()

This function will display the menu and ask user to enter a menu option 1-4. No numbers other than 1-4 should be accepted.

string getPhoneNumber()

This function will prompt user to enter a phone number in the format of 111-1111, where there should be 3 digits and a dash and another four digits.

double getFee()

This function will prompt user to enter a fee that is more or equal to 0

void enterSpeaker(SpeakBureau * speakers)

This function will prompt user to enter an index value to the speakers array, and allow user to enter speakers information to that index. Notice, if there is already a speaker stored at the index, prompt user to enter the index again.

Once a correct index has been entered, prompt user to enter a speakers name, phone number, topic and fee. (call getPhoneNumber and getFee function mentioned above)

Hint! You need cin.ignore()in this function.

void viewSpeaker(SpeakBureau * speakers)

This function will prompt user to enter an index value to the speakers array, and display the speakers information stored on that index. Display an error message and prompt user to enter again if the index entered is out of range or does not have a speaker on that index.

int countSpeaker(SpeakBureau * speakers, int size)

This function will display the number of speakers in the array, (notice, name - doesnt count as a real speaker)

Feel free to add more functions if needed

Sample Output:

************************************************************

1) enter a speaker

2) view a speaker info

3) display a count of how many speakers are in the list

4) quit

Please enter a choice: 1

Please enter an index to add the speaker: -9

!!!Error. Index out of range

Please enter an index to add the speaker: 1

Please enter the speaker's information:

Speaker name: John Doe

Phone number: Phone number: 12345

!!!Error. Incorrect format! Enter again

Phone number: 123-4567

Topic: C++

Fee: 0

************************************************************

1) enter a speaker

2) view a speaker info

3) display a count of how many speakers are in the list

4) quit

Please enter a choice: 1

Please enter an index to add the speaker: 9

Please enter the speaker's information:

Speaker name: Jane Doe

Phone number: Phone number: 456

!!!Error. Incorrect format! Enter again

Phone number: 456-7890

Topic: Programming II

Fee: 100

************************************************************

1) enter a speaker

2) view a speaker info

3) display a count of how many speakers are in the list

4) quit

Please enter a choice: 2

Please enter an index to view the speaker 1

Name: John Doe

Number: 123-456

Topic: C++

Fee: 0

************************************************************

1) enter a speaker

2) view a speaker info

3) display a count of how many speakers are in the list

4) quit

Please enter a choice: 2

Please enter an index to view the speaker 0

!!!Error. There is no speaker at that index

Please enter an index to view the speaker 9

Name: Jane Doe

Number: 456-7890

Topic: Programming II

Fee: 100

************************************************************

1) enter a speaker

2) view a speaker info

3) display a count of how many speakers are in the list

4) quit

Please enter a choice: 3

There are 2 speakers

************************************************************

1) enter a speaker

2) view a speaker info

3) display a count of how many speakers are in the list

4) quit

Please enter a choice: 4

Over!

It is imperative that you following the guidelines above. Please refrain from using complicated methods like switch statements. Please make sure the output of your program mimics the sample output above and include a screencap of your output.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions

Question

Please make it fast 4 6 1 . .

Answered: 1 week ago

Question

Understand why customers complain.

Answered: 1 week ago