Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

<?xml:namespace prefix = o ns = \"urn:schemas-microsoft-com:office:office\" /> Y

ID: 3540150 • Letter: #

Question

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

You have to write a program to help the school administrative stuffs to maintain student records. The program will allow the user to do the following tasks from the main control panel:

1.       Add Student

2.       Search student

3.       Show student list

4.       Find the school topper

5.       Exit

You may use any the class/lab resources but not internet.

Required Classes

The following classes need to be created for the exercise. Please note, in the class diagram, + and %u2013 denote public and private members respectively. Your class definition should match them accordingly.

The Student Class

The Sorted List class

The Main function

Create a Main function in main.cpp file and do the following:

1.         Load the Students from %u201CStudents.txt%u201D file into a SortedList object. In the file, each three lines contain the information of one student.

2.         Print the main control panel in the console.

3.         Take user input and process the request.

4.         Keep continuing the steps 2 and 3 unless user presses exit.

Task precedence

If you feel that you won%u2019t be able to complete the whole exercise within time, following is the task priority chart. Complete the task with higher priority first:

Priority

Task Name

1

Add Students (includes sort function)

2

Search Student

3

Show all students

4

Paginate student list

5

Find the class topper

The Sort Function

You may use any of the sort functions that you learned in the class to sort the student list.

The Search Function

Search a student by student id. The search function should be fast, therefore you should avoid linear search. Try for recursive binary search.

Hint: You may define a recursive function with all the parameters required, and then call the function from SearchById function passing appropriate parameters.

Show the student list in paginate format

While showing student list, if the number of students is more than ten, show first ten at once, then prompt the user to continue or exit. Keep printing the next ten as long as he continues. Sample Output:

Student                                Name                    CGPA

101                                         Adam                    3.0

102                                         Mary                      3.1

[List first ten students%u2026]

1. Continue

2. Cancel

Find the class topper

Find the student who has the highest CGPA. For this task, you have to devise your own logic. While creating your solution keep the following things in mind:

a.         Does it increase the complexity of the program?

b.         Does it take extra resources: memory space or looping through certain list?

Note: As your program would run in the computer, memory consumption is less important than the speed of execution. So if your solution requires extra memory however it increases the speed of the program by saving some loop iterations etc., then it%u2019s a better solution.

Answer the following question

1.         What is the complexity of your program?

e

Explanation / Answer

// i am providing you the defination and declaration of the class ,you just implemt the main function because i was not having time left


#include<iostream>

#include<string>



using namespace std;


class Student

{

private:

int m_id;

string m_name;

double m_cgpa;


public :

Student();

Student(int id, string name,double cgpa);

int getId();

string getName();

double getCgpa();

};


Student::Student()

{

m_id=-1;

m_name="";

m_cgpa=0.0;

}


Student::Student(int id, string name,double cgpa)

{

m_id=id;

m_name=name;

m_cgpa=cgpa;

}


int Student::getId()

{

return m_id;

}



string Student::getName()

{

return m_name;

}


double Student::getCgpa()

{

return m_cgpa;

}









class SortedList

{

private:

Student* m_list;

int m_size;

int m_noOfStudents;


public:

SortedList();

SortedList(int size);

Student* getSortedItems();

int getNoOfStudents();

void addStudents(Student students[],int size);

void remove(int index);

Student searchById(int id);

void increaseSize();

void sort();

};


SortedList::SortedList()

{

m_list=new Student[5];

m_noOfStudents=0;

m_size=5;

}


SortedList::SortedList(int size)

{

m_list=new Student[size];

m_noOfStudents=0;

m_size=size;


}


Student* SortedList::getSortedItems()

{

return m_list;

}


int SortedList::getNoOfStudents()

{

return m_noOfStudents;

}


void SortedList::addStudents(Student students[],int size)

{

if(m_noOfStudents+size>m_size)

{

Student* old_list=m_list;

m_size=m_noOfStudents+size;

m_list=new Student[m_size];


for(int i=0;i<m_noOfStudents;i++)

m_list[i]=old_list[i];

delete[] old_list;


}

int j;

int i;

for(i=m_noOfStudents,j=0;i<m_noOfStudents+size,j<size;i++,j++)

m_list[i]=students[j];



}

void SortedList::remove(int index)

{

if(index>=m_noOfStudents)

{

cout<<"index out of bound exception"<<endl;

}

else

{

for(int i=index+1;i<m_noOfStudents;i++)

{

m_list[i-1]=m_list[i];

}

}


}

int binarysearch(Student s[],int id,int low,int high)

{ int mid;

if (low > high)

return -1;

mid = (low + high)/2;

if(id == s[mid].getId())

{

return mid;

}

else if(id < s[mid].getId())

{ high = mid - 1;

binarysearch(s,id,low,high);

}

else if(id> s[mid].getId())

{ low = mid + 1;

binarysearch(s,id,low,high);

}

}

Student SortedList::searchById(int id)

{

int i;


i=binarysearch(m_list,id,0,m_noOfStudents-1);

if(i!=-1)

return m_list[i];


else

{

cout<<"student with given id is not found"<<endl;

Student s; // default student object;

return s;

}

}

void SortedList::increaseSize()

{

Student* old_list=m_list;

m_size=m_size+5;

m_list=new Student[m_size];


for(int i=0;i<m_noOfStudents;i++)

m_list[i]=old_list[i];

delete[] old_list;

}



void SortedList::sort()

{

for(int i=m_noOfStudents;i>0;i--)

{

for(int j=0;j<i;j++)

{

if(m_list[j].getId()>m_list[j+1].getId())

{

Student temp=m_list[j];

m_list[j]=m_list[j+1];

m_list[j+1]=temp;

}

}

}


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote