1. Engineering
  2. Computer Science
  3. in c write a class the requirements for the class...

Question: in c write a class the requirements for the class...

Question details

In C++ write a class. The requirements for the class are define as followings:

  • Class StudentMergeSortDriver – This class will contain the implementation of the main() method of the program. The following tasks will need to be implemented:
    • Prompt the user for the number of Student records to be entered.
    • Prompt the user to enter the information of each Student records up to the number of records specified above.
    • Print the original (unsorted) array.
    • Print the sorted array.

Code from the first two classes:

#pragma once
#include <string>
#include <iostream>

using namespace std;

class Student
{
public:
   string first_name;
   string last_name;
   string middle_name;
   int Student_ID;
   Student()
   {
       cout << "Enter first name=";
       cin >> first_name;
       cout << "Enter last name=";
       cin >> last_name;
       cout << "Enter ID=";
       cin >> Student_ID;
       cout << "Do you have Middle name(0 for no, 1 for yes)";
       int n;
       cin >> n;
       if (n)
       {
           cout << "Enter Middle name=";
           cin >> middle_name;
       }
   }
   };

class StudentBubbleSorter
{
public:
   void Sort(Student students_record[], int count) //Here function receiving array of student records and total count of records // for sorting
   {
       for (int i = 0; i < (count - 1); i++)
       {
           for (int j = 0; j < (count - i - 1); j++)
           {
               if (students_record[j].Student_ID > students_record[j + 1].Student_ID)
               {
                   Student temp = students_record[j];
                   students_record[j] = students_record[j + 1];
                   students_record[j + 1] = temp;
               }
           }
       }
   }
   void PrintRecords(Student students_record[], int count) //printing student records
   {
       cout << "Here is the sorted record date => \n";
       int i;
       for (i = 0; i < count; i++)
       {
           cout << students_record[i].Student_ID << "\n";
       }
   }

};

class StudentBubbleSortDriver
{
public:
   int create_array(Student students_record[])
   {

       int count, i;
       cout << "Enter no of students you want to insert";
       cin >> count;
       for (i = 0; i < count; i++)
       {
           Student;
       }

       return count; //Returning total number of records in array.
   }
};

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution