Question

11.9: Speakers Bureau Write a program that keeps track of a speaker's bureau. The program should...

11.9: Speakers Bureau

Write a program that keeps track of a speaker's 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 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.

It's only on myprogramminglab.com for the c++ language course.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include<iomanip>
using namespace std;

// Speaker structure
struct Speaker
{
string name;
string phone;
string topic;
double fee;
};

void display(Speaker speaker_array[], int total_speakers)
{
// Print header
cout<<left<<setw(15)<<"Name"<<left<<setw(15)<<"Phone"<<left<<setw(15)<<"Topic"<<left<<setw(15)<<"Fees"<<endl;

// Iterate over array and print all details of speakers
for(int i=0; i<total_speakers; i++)
{
cout<<left<<setw(15)<<speaker_array[i].name<<left<<setw(15)<<speaker_array[i].phone<<left<<setw(15)<<speaker_array[i].topic<<left<<setw(15)<<fixed<<setprecision(2)<<speaker_array[i].fee<<endl;
}
cout<<endl;
}

int main()
{
//size of array
int SIZE=5;
// Array of structure Speaker type
Speaker speaker_array[SIZE];
// Total speakers entered by user
int total_speakers = 0;
// Option to check if user wants to exit
int option = 0;

// Local variable
bool nameFound;
string name;
Speaker speaker;

// Iterate loop till option is not 4
while(option!=4)
{
// Display menu
cout<<"MENU: "<<endl;
cout<<"1) Add Speaker"<<endl;
cout<<"2) Change Speaker"<<endl;
cout<<"3) Display All Speakers"<<endl;
cout<<"4) Exit"<<endl;

// Ask to choose an option
cout<<"Enter option: ";
cin>>option;
cin.ignore();
// Use switch-case to determine which action to perform
switch(option)
{
case 1:
// Check if array is not full
// If not, ask for speakers details
// add speaker to array
// Increment total_speaker by 1
if(total_speakers<SIZE)
{
cout<<"Enter name: ";
getline(cin,speaker.name);
cout<<"Enter Phone number: ";
getline(cin,speaker.phone);
cout<<"Enter topic: ";
getline(cin,speaker.topic);
cout<<"Enter fees: ";
cin>>speaker.fee;
// Validate fee
while(speaker.fee<0)
{
cout<<"Enter fees: ";
cin>>speaker.fee;
}
cin.ignore();
speaker_array[total_speakers] = speaker;
total_speakers+=1;
}
else
{
cout<<"Array is full"<<endl;
}
break;
case 2:
// Ask for the speaker name to be changed
cout<<"Enter name of speaker to be changed: ";
getline(cin,name);
// set false initially
nameFound = false;
// Iterate over array, if name found
// ask for new details
// set nameFound to true
for(int i =0; i<total_speakers; i++)
{
if(speaker_array[i].name==name)
{
cout<<"Enter new name: ";
getline(cin,speaker_array[i].name);
cout<<"Enter Phone number: ";
getline(cin,speaker_array[i].phone);
cout<<"Enter topic: ";
getline(cin,speaker_array[i].topic);
cout<<"Enter fees: ";
cin>>speaker_array[i].fee;
while(speaker_array[i].fee<0)
{
cout<<"Enter fees: ";
cin>>speaker_array[i].fee;
}
cin.ignore();
nameFound = true;
break;
}
}
// If nameFound is false, means name is not found
if(!nameFound)
{
cout<<"Speaker does not exist"<<endl;
}
break;
case 3:
// call function to display content of array
display(speaker_array,total_speakers);
break;
case 4:
cout<<"Exit"<<endl;
break;
default:
cout<<"Invalid option"<<endl;
break;
}
cout<<endl;
}
return 0;
}

OUTPUT

Add a comment
Know the answer?
Add Answer to:
11.9: Speakers Bureau Write a program that keeps track of a speaker's bureau. The program should...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that keeps track of a speakers’ bureau. The program should use a structure...

    Write a program that keeps track of a speakers’ bureau. The program should use a structure to store the following data about a speaker: (this is in C++) Name Telephone Number Speaking Topic Fee Required The program should use a vector of structures. It should let the user enter data into the vector, change the contents of any element, and display all the data stored in the vector. The program should have a menu-driven user interface. Input Validation: When the...

  • Write a program that uses a structure to store the following data about a customer account: Name Address City, sta...

    Write a program that uses a structure to store the following data about a customer account: Name Address City, state, and ZIP Telephone number Account Balance Date of last payment The program should use an vector of at least 20 structures. It should let the user enter data into the vector, 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...

  • Write a program that uses a class or structure to store the following data about a...

    Write a program that uses a class or structure to store the following data about a customer account. Name Address City, State and Zip Telephone Number Account Balance Date of Last Payment The program should use an array or vector of 10 objects. It should let the users enter data, change the contents of any element and display all the data stored in the array or vector. The program should be modular and menu driven. Validation: When the data for...

  • Write a program (C++) that shows Game sales. The program should use a structure to store...

    Write a program (C++) that shows Game sales. The program should use a structure to store the following data about the Game sale: Game company Type of Game (Action, Adventure, Sports etc.) Year of Sale Sale Price The program should use an array of at least 3 structures (3 variables of the same structure). It should let the user enter data into the array, change the contents of any element and display the data stored in the array. The program...

  • Write a menu driven program to demonstrate the use of array and switch. It must be...

    Write a menu driven program to demonstrate the use of array and switch. It must be written in C language . Here is the menu - Press 1 to add a number to the array. Press 2 to display the numbers entered in the array so far Press 3 to find the average of the numbers entered. Press 4 to exit. Option 1 - The user should be able to enter 20 numbers only. If all twenty numbers are entered...

  • Write a Python program that keeps reading in names from the user, until the user enters...

    Write a Python program that keeps reading in names from the user, until the user enters 0. Once the user enters 0, you should print out all the information that was entered by the user. Use this case to test your program: Input: John Marcel Daisy Samantha Nelson Deborah 0 ================ Output: John Marcel Daisy 25 Samantha Nelson Deborah Hints: Create an array Names to hold the input names. Use the Names.append(x) function to add a new name to the...

  • Customer Accounts This program should be designed and written by a team of students. Here are...

    Customer Accounts This program should be designed and written by a team of students. Here are some suggestions: Write a program that uses a structure to store the following information about a customer account: • Name • Address • City, state, and ZIP • Telephone number • Account balance • Date of last payment The structure should be used to store customer account records in a file. The program should have a menu that lets the user perform the following...

  • Written in C++ language Write a program that keeps track of a telephone directory. The program...

    Written in C++ language Write a program that keeps track of a telephone directory. The program should create a structure, Person, with the following data: struct Person { string firstName; string lastName; string phoneNumber; }; The program should then create a vector of Person structs, called directory. Your program should have functions to: - Read the vector data from a data file “telephoneData.txt” into the vector directory. - Print the details of all Persons in the vector. You may use...

  • Write a C++ program that lets a maker of chips and salsa keep track of their...

    Write a C++ program that lets a maker of chips and salsa keep track of their sales for five different types of salsa they produce: mild, medium, sweet, hot, and zesty. It should use two parallel five-element arrays: an array of strings that holds the five salsa names and an array of integers that holds the number of jars sold during the past month for each salsa type. The salsa names should be stored using an initialization list at the...

  • Python 3.7 to be used. Just a simple design a program that depends on its own. You should also not need to import anythi...

    Python 3.7 to be used. Just a simple design a program that depends on its own. You should also not need to import anything. No code outside of a function! Median List Traversal and Exception Handling Create a menu-driven program that will accept a collection of non-negative integers from the keyboard, calculate the mean and median values and display those values on the screen. Your menu should have 6 options 50% below 50% above Add a number to the list/array...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT