// OrinTill Qimid CS1A Chapter 4, P. 294, 10
//
// /**************************************************************
// * Calculate monthly budget.
// *
// * ____________________________________________________________
// * This program will calculate the monthly budget.
// * ____________________________________________________________
// * INPUT
// * - Student spending on various categories such as rent, food, transportation, entertainment, etc.
// *
// * OUTPUT
// * - Total monthly spending.
// * - Analysis of whether the student is over or under budget.
// **************************************************************/
#include <iostream>
#include <string>
#include <vector>
using namespace std;
// Define the MonthlyBudget structure
struct Speaker {
string name;
string phoneNumber;
string topic;
double fee;
};
void addSpeaker(vector<Speaker>& speakers) {
Speaker newSpeaker;
cout << "Enter speaker's name: ";
cin.ignore();
getline(cin, newSpeaker.name);
cout << "Enter telephone number: ";
getline(cin, newSpeaker.phoneNumber);
cout << "Enter speaking topic: ";
getline(cin, newSpeaker.topic);
cout << "Enter fee required: ";
cin >> newSpeaker.fee;
speakers.push_back(newSpeaker);
}
void modifySpeaker(vector<Speaker>& speakers) {
int index;
cout << "Enter the index of the speaker to modify (0 - " << speakers.size() - 1 << "): ";
cin >> index;
if (index >= 0 && index < speakers.size()) {
cout << "Enter new speaker's name: ";
cin.ignore();
getline(cin, speakers[index].name);
cout << "Enter new telephone number: ";
getline(cin, speakers[index].phoneNumber);
cout << "Enter new speaking topic: ";
getline(cin, speakers[index].topic);
cout << "Enter new fee required: ";
cin >> speakers[index].fee;
} else {
cout << "Invalid index.\n";
}
}
void displaySpeakers(const vector<Speaker>& speakers) {
for (int i = 0; i < speakers.size(); ++i) {
cout << "\nSpeaker " << i + 1 << ":\n";
cout << "Name: " << speakers[i].name << "\n";
cout << "Telephone Number: " << speakers[i].phoneNumber << "\n";
cout << "Speaking Topic: " << speakers[i].topic << "\n";
cout << "Fee Required: $" << speakers[i].fee << "\n";
}
}
int main() {
vector<Speaker> speakers;
int choice;
do {
cout << "\nSpeakers Bureau Menu:\n";
cout << "1. Add Speaker\n";
cout << "2. Modify Speaker\n";
cout << "3. Display All Speakers\n";
cout << "4. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
addSpeaker(speakers);
break;
case 2:
modifySpeaker(speakers);
break;
case 3:
displaySpeakers(speakers);
break;
case 4:
cout << "Exiting the program.\n";
break;
default:
cout << "Invalid choice. Please try again.\n";
}
} while (choice != 4);
return 0;
}