Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Simple Student Information Database Implementation Programming language: C++ Database Description . Each record in the database has following fields: 1) 8 digit student ID 2)

Simple Student Information Database Implementation

Programming language: C++

Database Description. Each record in the database has following fields: 1) 8 digit student ID 2) Last name 3) First name 4) Telephone number 5) Major 6) GPA 7) Year of birth 8) Month of birth 9) Date of birth 10) Home address There is no predefined limitation on the number of records (linked list needed) I'll post this at the end Program behavior Initially the program should read a file to add some records into the database (You can create your own data file for initial input, or you can just hard code the data in your main program) Then the program needs to give interface for following operation repeatedly 1) insert a new record 2) delete record/records with given student ID 3) list all student information following the order they are saved 4) Reorder all student information following ascending/descending order by ID or GPA or birthday (consider year, month and date together) 5) list students in a given major, or a given ID Very Important part 1) Organize code in classes with proper .h and .cpp file structure 2) Submit readme file explaining the interface in your design 3) You can use any sorting algorithm discussed in class ( stack queue, and deque )

What to submit 1) All source codes 2) Readme file

_______________________________________________________________LinkedList.h___________________________________________________________

#ifndef LINKEDLIST_H #define LINKEDLIST_H class Node { private: int data; Node *next; public: Node(); int GetData(); friend class LinkedList; }; class LinkedList { private: int length; Node *currentPos; Node *head; Node *tail; public: LinkedList(); ~LinkedList(); int LengthIs(); void MakeEmpty(); void AddToTail(int); void AddToHead(int); int SearchRank(int); void DeleteFromHead(); void DeleteFromTail(); void Delete(int); Node GetNext(); bool IsLast(); void Reset(); void PrintAll(); }; #endif 

____________________________________________________________________________________________________________________________________

_________________________________________________________________________LinkedList.cpp________________________________________________

#include "LinkedList.h" #include  using namespace std; Node::Node() { next = 0; } int Node::GetData() { return data; } LinkedList::LinkedList() { length = 0; head = 0; tail = 0; currentPos = 0; } int LinkedList::LengthIs() { return length; } void LinkedList::MakeEmpty() { Node *ptr = head; Node *ptr2; for(int i=0;inext; delete ptr; ptr = ptr2; } length = 0; head = tail = currentPos = 0; } void LinkedList::AddToTail(int item) { Node *ptr=new Node(); ptr->data = item; if(length==0) { tail = ptr; head = ptr; length++; return; } tail->next = ptr; tail = ptr; length++; } void LinkedList::AddToHead(int item) { Node *ptr = new Node; ptr->data = item; ptr->next = head; head = ptr; if(length==0) tail = ptr; length++; } int LinkedList::SearchRank(int value) { int rank = 0; Node *current = head; while(current) { if(current->data == value) return rank; rank++; current = current->next; } return -1; } void LinkedList::DeleteFromHead() { if(length == 0) return; Node *ptr = head->next; if(currentPos==head) currentPos = 0; delete head; head = ptr; length--; if(length == 0) tail = 0; } void LinkedList::DeleteFromTail() { if(length==0) return; else if (length==1) { delete head; head = tail =currentPos = 0; length--; return; } Node *current = head; for(int i=0;inext; tail = current; if(currentPos == current->next) currentPos = 0; delete current->next; current->next = 0; length--; return; } bool LinkedList::IsLast() { if(currentPos==tail) return 1; else return 0; } void LinkedList::Reset() { currentPos = 0; } Node LinkedList::GetNext() { Node temp; if(currentPos==0) { if(head) temp.data = head->data; else temp.data = -1; currentPos = head; } else { if(currentPos->next!=0) { temp.data = currentPos->next->data; currentPos=currentPos->next; } else temp.data = -1; } return temp; } LinkedList::~LinkedList() { MakeEmpty(); } void LinkedList::PrintAll() { Node *current = head; while(current) { cout<data<next; } } 

____________________________________________________________________________________________________________________________________

_____________________________________________________________________LinkedListprog.cpp________________________________________________

#include "LinkedList.h"; #include  using namespace std; int main() { LinkedList myList; for(int i=0;i<20;i++) myList.AddToTail(i); myList.DeleteFromHead(); myList.DeleteFromTail(); cout< 

____________________________________________________________________________________________________________________________________

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions

Question

KEY QUESTION Refer to Figure 3.6, page

Answered: 1 week ago