Thread: Switch case and enum help

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    7

    Structure and enum help

    I am starting to get used to the use of switch case and enum... Basically, all that I need to learn all the basics of what I need is how I'm supposed to personally record information without having to manually go into the code.

    I want to simply type in the information and have it recorded into the appopriate value... instead of simply having it instantly record a pre-made value.

    Code:
    #include <iostream.h>
    using namespace std;
    
    enum athel_names { Ed, Joe, Bill, Dan};
    enum class_level { Freshman, Sophomore, Junior, Senior, Drop_Out, Graduate };
    enum sport_teams { Football, Basketball, Baseball, None };
    enum grade_acept { Yes, No };
    
    struct students
    {
    athel_names an;
    class_level cl;
    sport_teams st;
    grade_acept ga;
    };
    
    int main()
    {
    students sport;
        
    sport.an = Ed;
    sport.cl = Senior;
    sport.st = Football;
    sport.ga = No;
    
    system("cls");
    
      switch ( sport.an ) {
      case Ed:
        cout << "Ed\n";    
        break;
      case Joe:         
        cout << "Joe\n";    
        break;
      case Bill:           
        cout << "Bill\n";    
        break;
      case Dan:        
        cout << "Dan\n";  
        break;
      default:     
        break;
      }
    
    system("pause");
    }
    Basically, this system records the information on 4 people (Either Ed, Joe, Bill, or Dan), which school class they are in (Freshman, Sophomore, Junior, Senior, Drop Out, or Graduate), what sport they would wish to take (Football, Basketball, Baseball, or None), and if their grades are/were acceptable to allow them to take a sport... Not a real life situation, but it works...

    The problem isn't in the coding (Though, it may be somewhat inefficiant due to me being a novice), because it works, the problem lies in my need to type in the information... Sort of typing in a normal integer with cin.

    Sorry for the lengthy post, and whether or not I get help, thanks for your time! n_n
    Last edited by SomeCrazyGuy; 04-17-2005 at 09:05 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Segmentation fault!?!?!?
    By Viper187 in forum Windows Programming
    Replies: 57
    Last Post: 10-02-2008, 09:40 PM
  2. Can someone please clean up my code
    By ki113r in forum C Programming
    Replies: 10
    Last Post: 09-12-2007, 10:03 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. enumeration with switch case?
    By Shadow12345 in forum C++ Programming
    Replies: 17
    Last Post: 09-26-2002, 04:57 PM
  5. What enum got to do with it?
    By correlcj in forum C Programming
    Replies: 4
    Last Post: 07-18-2002, 08:12 PM