fork download
  1. //Alessandro Iniguez CSC5 Chapter 11, P. 646, #9
  2. //
  3. /******************************************************************************
  4.  *
  5.  * SPEAKER BUREAU
  6.  * _____________________________________________________________________________
  7.  * The program should use an array of at least 10 structures. It should let the
  8.  * user enter data into the array, change the contents of any element, and
  9.  * display all the data stored in the array. The program should have a
  10.  * menu-driven user interface
  11.  * _____________________________________________________________________________
  12.  * INPUT
  13.  * menu
  14.  * enter : enter info
  15.  * telephoneNumber : the number of person
  16.  *
  17.  * OUTPUT
  18.  * leave : time leaving
  19.  * search : searching person
  20.  *
  21.  ******************************************************************************/
  22. #include <iostream>
  23. #include <string>
  24. #include <iomanip>
  25.  
  26. using namespace std;
  27.  
  28. struct speakerBureau
  29. {
  30. string name;
  31. string TelephoneNumber;
  32. string SpeakTopic;
  33. int fee;
  34. };
  35.  
  36. void getSpeaker(speakerBureau *);
  37. void printSpeaker(speakerBureau *);
  38. void editSpeaker(speakerBureau *);
  39. void searchSpeakTopic(speakerBureau*);
  40.  
  41. int main()
  42. {
  43. int NUM_SPEAKERS = 10;
  44. int index;
  45. speakerBureau info[10];
  46.  
  47. int menu;
  48. const int enter = 1,
  49. change = 2,
  50. print = 3,
  51. search = 4,
  52. leave = 5;
  53.  
  54. do{
  55. cout << "Please select a choice from the menu.\n"
  56. << "1) Enter Speaker Information.\n"
  57. << "2) Change Speaker Information.\n"
  58. << "3) Print Speaker Information.\n"
  59. << "4) Search for Topic. \n"
  60. << "5) Leave this menu.\n"
  61. << "Select: ";
  62. cin >> menu;
  63.  
  64.  
  65. switch (menu)
  66. {
  67. case enter:
  68. {
  69.  
  70.  
  71. getSpeaker(info);
  72. }
  73. break;
  74. case change:
  75. {
  76.  
  77. editSpeaker(info);
  78. }
  79. break;
  80. case print:
  81. {
  82.  
  83. printSpeaker(info);
  84. }
  85. break;
  86.  
  87.  
  88. case search:
  89. {
  90. searchSpeakTopic(info);
  91. }
  92. }
  93. } while (menu != leave);
  94.  
  95.  
  96. system("pause");
  97. return 0;
  98. }
  99. void getSpeaker(speakerBureau *p)
  100. {
  101.  
  102. int i = 0;
  103. int size = 10;
  104. for (i = 0; i < size; i++)
  105. {
  106. cout << "Please enter the following information of speaker " << i << " : \n";
  107. cout << "Speaker Name:";
  108. cin.ignore();
  109. getline(cin, p[i].name);
  110. cout << "\nSpeaker Telephone Number:";
  111. cin.ignore();
  112. getline(cin, p[i].TelephoneNumber);
  113. cout << "\nSpeaker Topic:";
  114. cin.ignore();
  115. getline(cin, p[i].SpeakTopic);
  116. cout << "\nFee Required:";
  117. cin >> p[i].fee;
  118. }
  119. }
  120.  
  121.  
  122. void printSpeaker(speakerBureau *p)
  123. {
  124. int i = 0;
  125. int size = 10;
  126. for (i = 0; i < size; i++)
  127. {
  128. cout << "The information entered for each speaker is: \n";
  129. cout << "Speaker " << i << endl;
  130. cout << "Speaker Name: " << p[i].name << endl;
  131. cout << "Speaker Telephone Number: " << p[i].TelephoneNumber << endl;
  132. cout << "Speaker Topic: " << p[i].SpeakTopic << endl;
  133. cout << "Speaker Fee Required: " << p[i].fee << endl;
  134. }
  135. }
  136.  
  137. void editSpeaker(speakerBureau *p)
  138. {
  139. int i;
  140. cout << "Please enter the number of the speaker you would like to edit."
  141. << endl;
  142. cin >> i;
  143. if (i <= 9)
  144. {
  145. cout << endl;
  146. cout << "Please enter the updated information of the speaker: \n";
  147. cout << "Speaker Name:";
  148. cin.ignore();
  149. getline(cin, p[i].name);
  150. cout << "\nSpeaker Telephone Number:";
  151. getline(cin, p[i].TelephoneNumber);
  152. cout << "\nSpeaker Topic:";
  153. getline(cin, p[i].SpeakTopic);
  154. cout << "\nFee Required:";
  155. cin >> p[i].fee;
  156. }
  157. else
  158. {
  159. cout << "Please pick a number between 0-9" << endl;
  160.  
  161.  
  162. }
  163. }
  164.  
  165.  
  166. void searchSpeakTopic(speakerBureau*p)
  167. {
  168. int i = 0;
  169. int topic;
  170.  
  171.  
  172. cout << " Please type a topic in the program" << endl;
  173.  
  174.  
  175. cin >> topic;
  176.  
  177.  
  178. }
Success #stdin #stdout #stderr 0.01s 5280KB
stdin
5
stdout
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: 
stderr
sh: 1: pause: not found