Use C++ (use prototypes function) Write a program that keeps track of a speakers
ID: 3712839 • Letter: U
Question
Use C++ (use prototypes function)
Write a program that keeps track of a speakers' bureau. The program should use a structure to store the following data about a speaker:
Name
Telephone Number
Speaking Topic
Fee Required
The program should use an array of at least 10 structures. It should let the user enter data into the array, change the contents of any element, and display all the data stored in the array. The program should have a menu-driven user interface.
Input Validation: When the data for a new speaker is entered, be sure the user enters data for all the fields. No negative amounts should be entered for a speaker's fee.
Please, comment your code.
Explanation / Answer
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
struct speakerBureau
{
string name;
string TelephoneNumber;
string SpeakTopic;
int fee;
};
void getSpeaker(speakerBureau *);
void printSpeaker(speakerBureau *);
void editSpeaker(speakerBureau *);
void searchSpeakTopic(speakerBureau*);
int main()
{
int NUM_SPEAKERS = 10;
int index;
speakerBureau info[10];
int menu;
const int enter = 1,
change = 2,
print = 3,
search = 4,
leave = 5;
do{
cout << "Please select a choice from the menu. "
<< "1) Enter Speaker Information. "
<< "2) Change Speaker Information. "
<< "3) Print Speaker Information. "
<< "4) Search for Topic. "
<< "5) Leave this menu. "
<< "Select: ";
cin >> menu;
switch (menu)
{
case enter:
{
getSpeaker(info);
}
break;
case change:
{
editSpeaker(info);
}
break;
case print:
{
printSpeaker(info);
}
break;
case search:
{
searchSpeakTopic(info);
}
}
} while (menu != leave);
system("pause");
return 0;
}
void getSpeaker(speakerBureau *p) //array name = pointer
{
int i = 0;
int size = 10;
for (i = 0; i < size; i++)
{
cout << "Please enter the following information of speaker " << i << " : ";
cout << "Speaker Name:";
cin.ignore();
getline(cin, p[i].name);
cout << " Speaker Telephone Number:";
cin.ignore();
getline(cin, p[i].TelephoneNumber);
cout << " Speaker Topic:";
cin.ignore();
getline(cin, p[i].SpeakTopic);
cout << " Fee Required:";
cin >> p[i].fee;
}
}
void printSpeaker(speakerBureau *p)
{
int i = 0;
int size = 10; // Array size
for (i = 0; i < size; i++)
{
cout << "The information entered for each speaker is: ";
cout << "Speaker " << i << endl;
cout << "Speaker Name: " << p[i].name << endl;
cout << "Speaker Telephone Number: " << p[i].TelephoneNumber << endl;
cout << "Speaker Topic: " << p[i].SpeakTopic << endl;
cout << "Speaker Fee Required: " << p[i].fee << endl;
}
}
void editSpeaker(speakerBureau *p)
{
int i;
cout << "Please enter the number of the speaker you would like to edit."
<< endl;
cin >> i;
if (i <= 9)
{
cout << endl;
cout << "Please enter the updated information of the speaker: ";
cout << "Speaker Name:";
cin.ignore();
getline(cin, p[i].name);
cout << " Speaker Telephone Number:";
getline(cin, p[i].TelephoneNumber);
cout << " Speaker Topic:";
getline(cin, p[i].SpeakTopic);
cout << " Fee Required:";
cin >> p[i].fee;
}
else
{
cout << "Please pick a number between 0-9" << endl;
}
}
void searchSpeakTopic(speakerBureau*p)
{
int i = 0;
int topic;
cout << " Please type a topic in the program" << endl;
cin >> topic;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.