title: C++: Student Record Program
body: <p>I am in desperate need of help. I am supposed to create a student record using structs and vectors.
  In the program, I should have:</p>
  
  <ol>
  <li><p>For a given student, identified either by name or student number
  (a) Enter a new student into the record. (Assume no courses completed.)
  (b) Grade point average
  (c) Transcript, i.e. a list of courses taken, including credit value and grade earned
  (d) Record a newly completed course</p></li>
  <li><p>A listing, sorted by name, of all students who have taken a given course.</p></li>
  <li><p>A listing, sorted by grade point average, of all students and their grade point averages,
  who are on probation, i.e. have a grade point average &lt; 2.0 .</p></li>
  </ol>
  
  <p>This is what I have so far... and I seem to be having troubles with the user input how read it into my structs</p>
  
  <pre><code>using namespace std;
  
  struct courses {
      string courseName;
      int courseNum;
      double credit;
      char grade;
  };
  
  struct students {
      string name;
      int id;
      vector&lt;courses&gt; c;
  };
  
  int main() {
  
      // variables
      string name;
      char selector;
      students s;
      courses d;
      vector&lt;students&gt; student;
      vector&lt;courses&gt; course;
  
      // (1) create a menu: (a) user input, (b) echo record (with overall gpa), (c) failed students
      do {
          // prompt for user input
          cout &lt;&lt; "Enter Q to (Q)uit, (C)reate new student record, (S)how all record(s) on file, show students on (P)robation: ";
          cin &gt;&gt; selector;
  
          selector = toupper(selector);
          switch (selector) {
  
  
  
              // (a) ask and get for user input:
              // student info first
              // courses second
          case 'C':
  
              // variables within case C
              char answer;
              char answerAddAnotherCourseEntry;
              char answerToAnotherStudentRecord;
  
              do {
  
  
                  cout &lt;&lt; "Enter your name and student ID number: ";
                  cin &gt;&gt; s.name &gt;&gt; s.id;
                  student.push_back(s);
  
                  do {
                      cout &lt;&lt; "Do you want to create a student course entry ('y' or 'n')? ";
                      cin &gt;&gt; answer;
                      answer = toupper(answer);
  
                      cout &lt;&lt; "Enter your course number, course name, grade received and credit worth: ";
                      cin &gt;&gt; d.courseNum &gt;&gt; d.courseName &gt;&gt; d.grade &gt;&gt; d.credit;
                      course.push_back(d);
  
  
                      cout &lt;&lt; "Add another student course entry ('y' or 'n'): ";
                      cin &gt;&gt; answerAddAnotherCourseEntry;
                      answerAddAnotherCourseEntry = toupper(answerAddAnotherCourseEntry);
  
  
                  } while (answer == 'N');
  
                  cout &lt;&lt; "Add another student record ('y' or 'n'): " &lt;&lt; endl;
                  cin &gt;&gt; answerToAnotherStudentRecord;
                  answerAddAnotherCourseEntry = toupper(answerToAnotherStudentRecord);
              } while (answerToAnotherStudentRecord == 'N');
              break;
  
  
              // (b) echo record of vectors
              // sort by name
          case 'S':
              if (student.empty()) {
                  cout &lt;&lt; "\nSorry, no records exist in the database.";
              }
              else
                  for (int count = 0; count &lt; student.size(); count++) {         //For Loop to Display All Records
  
                      cout &lt;&lt; "Student name: " &lt;&lt; student[count].name &lt;&lt; "ID Number: " &lt;&lt; student[count].id &lt;&lt; endl;
                      count++;
  
                      // another for loop i think
                      for (int i = 0; i &lt; course.size(); i++) {
                          cout &lt;&lt; "Course info: " &lt;&lt; " " &lt;&lt; course[i].courseNum &lt;&lt; " " &lt;&lt; course[i].courseName &lt;&lt; " " &lt;&lt; course[i].credit &lt;&lt; " " &lt;&lt; course[i].grade &lt;&lt; endl;
                          i++;
                      }
                  }
              cout &lt;&lt; endl;
              break;
  
  
              // (c) separate failed student into another vector
              // sort by gpa
          case 'P':
              break;
  
  
  
  
          } // bracket closing switch
      } // bracket closing do while
      while (selector != 'q' &amp;&amp; selector != 'Q');     // first do while
  </code></pre>