3nriched

Untitled

Apr 3rd, 2011
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.89 KB | None | 0 0
  1. // SpeaksBureauCool.cpp : Defines the entry point for the console application.
  2. //
  3. #include "stdafx.h"
  4. #include <iostream>
  5. #include <iomanip>
  6. using namespace std;
  7.  
  8. struct Speaks
  9. {
  10.         char Name[30];
  11.         int Telephone;
  12.         char Topic[100];
  13.         double Fee;
  14. };
  15.  
  16. void Menu(int NUM_SPEAKIERS,Speaks speakIers[]);
  17.  
  18. void showSpeakers(int NUM_SPEAKIERS,Speaks speakIers[])
  19. {
  20.     cout<<endl;
  21.    
  22.     for(int i =1;i<NUM_SPEAKIERS+1;i++)
  23.     {
  24.         cout<<endl;
  25.         cout<<"Speaker "<<i<<".\n";
  26.         cout<<speakIers[i-1].Name<<"\t\t"<<speakIers[i-1].Topic<<endl;
  27.         cout<<speakIers[i-1].Telephone<<"\t\t"<<speakIers[i-1].Fee<<endl;
  28.         cout<<endl;
  29.  
  30.     }
  31.         cout<<"Current list of speakers.\n";
  32.         cout<<endl;
  33.         system("pause");
  34.         system("cls");
  35.         Menu(NUM_SPEAKIERS, speakIers);
  36.  
  37. }
  38.  
  39.  void editSpeaker(int NUM_SPEAKIERS,Speaks speakIers[])
  40. {
  41.     cout<<endl;cout<<endl;cout<<endl;                                                       //cleanfill
  42.     int speakerEditPick = 0;
  43.     for(int i =1;i<NUM_SPEAKIERS+1;i++)
  44.     {
  45.         cout<<endl;
  46.         cout<<"Speaker "<<i<<": "<<speakIers[i-1].Name<<"\t\t"<<speakIers[i-1].Topic<<endl;
  47.         cout<<endl;
  48.     }
  49.  
  50.     do{
  51.     cout<<"Please enter the speaker number you wish to modify: ";
  52.     cin>>speakerEditPick;
  53.     cout<<endl;
  54.     system("cls");
  55.     }while(speakerEditPick < 1 || speakerEditPick > 10);
  56.  
  57.     cout<<"You have chosen to modify speaker "<<speakerEditPick<<".\n";
  58.     cout<<endl;
  59.  
  60.                 //get the new speakers name
  61.                 cout<<"Enter Speaker "<<speakerEditPick<<"'s Name: ";
  62.                 cin>>speakIers[speakerEditPick-1].Name;
  63.  
  64.                 //get the new speaker's phone numbers
  65.                 cout<<"Enter speaker's phone number (integers only): ";
  66.                 cin>>speakIers[speakerEditPick-1].Telephone;
  67.  
  68.                 //gets the new topic for each speaker
  69.                 cout<<"Enter the topic for this speaker: ";
  70.                 cin>>speakIers[speakerEditPick-1].Topic;
  71.  
  72.                 //gets the new fee speaker is charged
  73.                 cout<<"Enter speaker price: $";
  74.                 cin>>speakIers[speakerEditPick-1].Fee;
  75.                 cout<<endl;
  76.  
  77.                 system("pause");
  78.                 system("cls");
  79.  
  80.                 cout<<endl;
  81.                 cout<<"Speaker "<<speakerEditPick<<".\n";
  82.                 cout<<speakIers[speakerEditPick-1].Name<<"\t\t"<<speakIers[speakerEditPick-1].Topic<<endl;
  83.                 cout<<speakIers[speakerEditPick-1].Telephone<<"\t\t"<<speakIers[speakerEditPick-1].Fee<<endl;
  84.                 cout<<endl;
  85.                 cout<<"You have successfully modified the information regarding speaker "<<speakerEditPick<<".\n";
  86.                 cout<<endl;
  87.                 system("pause");
  88.                 system("cls");
  89.                 Menu(NUM_SPEAKIERS, speakIers);
  90.  
  91. }
  92. void setSpeakers(int NUM_SPEAKIERS,Speaks speakIers[])
  93. {
  94.    
  95. //get speaker data
  96.         cout<<"Enter the following information on the "<<NUM_SPEAKIERS
  97.                 <<" speakers, who will be speaking at the event.\n";
  98.         int index=0;
  99.         for(index = 0;index<NUM_SPEAKIERS;index++)
  100.         {
  101.                 //get the speakers names
  102.                 cout<<"Enter Speaker "<<(index+1)<<"'s Name: ";
  103.                 cin>>speakIers[index].Name;
  104.  
  105.                 //get the speaker's phone numbers
  106.                 cout<<"Enter speaker's phone number (integers only): ";
  107.                 cin>>speakIers[index].Telephone;
  108.  
  109.                 //gets the topic for each speaker
  110.                 cout<<"Enter the topic for this speaker: ";
  111.                 cin>>speakIers[index].Topic;
  112.  
  113.                 //gets the fee speaker is charged
  114.                 cout<<"Enter speaker price: $";
  115.                 cin>>speakIers[index].Fee;
  116.                 cout<<endl;
  117.         }
  118.         system("pause");
  119.         system("cls");
  120.         Menu(NUM_SPEAKIERS, speakIers);
  121.        
  122. }
  123.  
  124. void Credits(int NUM_SPEAKIERS,Speaks speakIers[])
  125. {
  126.    
  127.     cout<<endl;cout<<endl;cout<<endl;
  128.        
  129.                 cout<<"\t\t\t>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n";
  130.                 cout<<"\t\t\t^          Created by:           v\n";                        ///////////////////
  131.                 cout<<"\t\t\t^     --------------------       v\n";                        //  Sweet Menu   //
  132.                 cout<<"\t\t\t^              Me                v\n";                        ///////////////////
  133.                 cout<<"\t\t\t^              Me                v\n";
  134.                 cout<<"\t\t\t^              Me                v\n";
  135.                 cout<<"\t\t\t<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n";
  136.                 cout<<endl;cout<<endl;                                                                          //clean fill
  137.                 system("pause");
  138.                 system("cls");
  139.                 Menu(NUM_SPEAKIERS, speakIers);
  140. }
  141.  
  142. void exitrlly(int NUM_SPEAKIERS,Speaks speakIers[])
  143. {
  144.     char rllygo;                                                        //holds user inputted char
  145.     cout<<"\t\t\t    Leaving so soon??\n";                  //title of exit page
  146.     cout<<endl;cout<<endl;                                          //clean fill
  147.     cout<<"Are you sure you wish to exit the program?(y or n): ";       //makes sure user wants to leave
  148.     cin>>rllygo;                                            //assigns user inputted choice to variable
  149.  
  150.         if(rllygo == 'y')                                          //tests if y was entered
  151.         {
  152.             exit (0);                                         //exits the program
  153.         }  
  154.            
  155.             system("cls");                                 //refresh screen
  156.             Menu(NUM_SPEAKIERS, speakIers);                     //reloads menu             
  157. }
  158.  
  159. void searchTopics(int NUM_SPEAKIERS,Speaks speakIers[])
  160. {
  161.     //string keyWord;?
  162.     cout<<endl;
  163.     cout<<"Enter a topic keyword: ";
  164.     cout<<endl;
  165.     cout<<"This option is not available in the free version.\n";
  166.     cout<<endl;
  167.     cout<<"Send me $5 for a better version.\n";
  168.     cout<<endl;
  169.     system("pause");
  170.     system("cls");
  171.     Menu(NUM_SPEAKIERS, speakIers);                     //reloads menu
  172.  
  173.     //cin.getline(keyWord);??
  174.  
  175.    
  176. }
  177. void Menu(int NUM_SPEAKIERS,Speaks speakIers[])
  178. {
  179.  
  180.         system("cls");
  181.         int menuChoice = 0;                                                                                     //initialized to 0, holds menu selection of user
  182.         do                                                                                //loops the menu - handles out of range integer input
  183.         {
  184.         cout<<endl;cout<<endl;cout<<endl;
  185.        
  186.                 cout<<"\t\t\t>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n";
  187.                 cout<<"\t\t\t^ 1 - Initialize All Speakers    v\n";                        ///////////////////
  188.                 cout<<"\t\t\t^ 2 - Edit Individual Speaker    v\n";                        //  Sweet Menu   //
  189.                 cout<<"\t\t\t^ 3 - Display Speaker List       v\n";                        ///////////////////
  190.                 cout<<"\t\t\t^ 4 - Search Topics              v\n";
  191.                 cout<<"\t\t\t^ 5 - Credits                    v\n";
  192.                 cout<<"\t\t\t^ 6 - Exit                       v\n";
  193.                 cout<<"\t\t\t<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n";
  194.                 cout<<endl;cout<<endl;                                                                          //clean fill
  195.  
  196.                 cin>>menuChoice;                                                                                        //assigns user selection to variable
  197.  
  198.                 if(menuChoice == 1)                                                                                     //tests for option 1 selection
  199.                 {
  200.                         system("cls");                                                                                  //resets screen
  201.                         setSpeakers(NUM_SPEAKIERS, speakIers);                            
  202.                 }
  203.                         if(menuChoice == 2)                                                                             //tests for option 2 selection                
  204.                         {
  205.                                 system("cls");                                                                          //refreshes screen
  206.                                 editSpeaker(NUM_SPEAKIERS, speakIers);
  207.                         }
  208.                                 if(menuChoice == 3)                                                                     //tests for option 3 selection
  209.                                 {
  210.                                         system("cls");                                                                  //refreshes screen
  211.                                         showSpeakers(NUM_SPEAKIERS, speakIers);
  212.                                 }
  213.                                         if(menuChoice == 4)                                                             //tests for option 4 selection
  214.                                         {
  215.                                                 system("cls");                                                          //refreshes screen
  216.                                                 searchTopics(NUM_SPEAKIERS, speakIers);
  217.                                         }
  218.                                                 if(menuChoice == 5)                                                     //tests for option 5 selection
  219.                                                 {
  220.                                                         system("cls");                                                  //refreshes screen
  221.                                                         Credits(NUM_SPEAKIERS, speakIers);
  222.                                                 }
  223.                                                         if(menuChoice == 6)                                                     //tests for option 5 selection
  224.                                                         {
  225.                                                                  system("cls");                                                  //refreshes screen
  226.                                                                  exitrlly(NUM_SPEAKIERS, speakIers);
  227.                                                          }
  228.                                                                                        
  229.  
  230.         }while(menuChoice < 1 || menuChoice > 6);                                                       //loop handler for menuchoices not available
  231. }
  232.  
  233. int main(int argc, char* argv[])
  234. {
  235.         const int NUM_SPEAKERS = 10;   //number of speakers
  236.         Speaks speakers[NUM_SPEAKERS];   //array of structures
  237.        
  238.         Menu(NUM_SPEAKERS, speakers);
  239.  
  240.         system("pause");
  241.         return 0;
  242. }
Add Comment
Please, Sign In to add comment