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

using c++ Programming Project 2: The linked list - Reference: chapter 18: a.Crea

ID: 3745728 • Letter: U

Question

using c++

Programming Project 2: The linked list - Reference: chapter 18:

a.Create an array of 15 student records that should not be sorted.

b.Create a liked list of 15 student record nodes. Each node is a node of one student record from the above unsorted array.

(Append Function)

c.Each student record consists of student ID, student name, Student address, and GPA.

d.The student records must be defined as student object class with member functions. (No class definition declaration will be no credit for the project.)

e.Turn in source programs and Execution output:

1.Display the student records from the unsorted array

2.Display the student records from the unsorted linked list

(Display function)

f.You can not use the high level STL library or functions such as

container classes or container adapter classes if you know how to use them (section 17.1 in ninth edition.)

If you do not know, just ignore this statement.

Notes: Turn in with hard copy and must be professional and the turn-in should include the source Program, and the displayed outputs as described above. Proper messages in the output are required to indicate the execution and different outputs.

Explanation / Answer

// All questions covered in the following c++ program

#include<conio.h>
#include<iostream>
#include<fstream>
#include<cctype>
#include<sstream>
#include<string>
using namespace std;
bool check = true;
struct node //structure of node //
{
char Stuname[20]; //name of the student
char StuAddress[30]; // address of the student
int StuID; //ID of the student
float GPA;
node *next;
}*head,*lastptr;

void addrecords() //Adds record of student//
{
node *p;
p=new node;
cout<<"Enter name of student:"<<endl;
gets(p->Stuname);
fflush(stdin);
cout<<"Enter Address of student:"<<endl;
gets(p->StuAddress);
fflush(stdin);
cout<<"Enter ID of the student:"<<endl;
cin>>p->StuID;
fflush(stdin);
cout<<"Enter GPA of student:"<<endl;
cin>>p->GPA;
fflush(stdin);
p->next=NULL;

if(check)
{
head = p;
lastptr = p;
check = false;
}
else
{
lastptr->next=p;
lastptr=p;
}
cout<<endl<<"Record has been Entered";
getch();
}
void modify() //modifies record of the student//
{
node *ptr;
node *prev=NULL;
node *current=NULL;
int student_id;
cout<<"Enter Student ID to search:"<<endl;
cin>>student_id;
prev=head;
current=head;
while(current->StuID!=student_id)
{
prev=current;
current=current->next;
}
ptr=new node;
fflush(stdin);
cout<<"Enter name of student:"<<endl;
gets(ptr->Stuname);
fflush(stdin);
cout<<"Enter Address of student:"<<endl;
gets(ptr->StuAddress);
fflush(stdin);
cout<<"Enter Student ID of student:"<<endl;
cin>>ptr->StuID;
fflush(stdin);
cout<<"Enter GPA of student:"<<endl;
cin>>ptr->GPA;
fflush(stdin);
prev->next=ptr;
ptr->next=current->next;
current->next=NULL;
delete current;
cout<<endl<<"Recored Modified";
getch();
}
void search() //searches record of student//
{
node *prev=NULL;
node *current=NULL;
int student_id;
cout<<"Enter Roll Number to search:"<<endl;
cin>>student_id;
prev=head;
current=head;
while(current->StuID!=student_id)
{
prev=current;
current=current->next;
}
cout<<" Student name: ";
puts(current->Stuname);
cout<<" ID of student:";
cout<<current->StuID;
cout<<" Student Address:";
puts(current->StuAddress);
cout<<" Student GPA:";
cout<<current->GPA;
getch();
}
void del() //deletes record of a student//
{
node *ptr=NULL;
node *prev=NULL;
node *current=NULL;
int student_id;
cout<<"Enter ID to Delete:"<<endl;
cin>>student_id;
prev=head;
current=head;
while(current->StuID!=student_id)
{
prev=current;
current=current->next;
}
prev->next = current->next;
current->next=NULL;
delete current;
cout<<endl<<"Recored Deleted";
getch();
}

int main()
{
char x;
cout<<" ********************************* "<<endl;
cout<<" ****STUDENT MANAGEMENT SYSTEM**** "<<endl;
cout<<" ********************************* "<<endl;
cout<<"…………………………………….."<<endl;
cout<<"…………………"<<endl;
cout<<"……………………………………………………."<<endl;
cout<<" Press Any Key To Continue . . . ."<<endl;
getch();
do
{
  
cout<<"1--->Press '1' to add New record:"<<endl;
cout<<"2--->Preswins '2' to search a record:"<<endl;
cout<<"3--->Press '3' to modify a record:"<<endl;
cout<<"4--->Press '4' to delete a record:"<<endl;
cout<<"5--->Press '5' to exit:"<<endl;
x=getch();
if(x=='1')
{

addrecords();
}
else if(x=='2')
{
  
search();
}
else if(x=='3')
{
  
modify();
}
else if(x=='4')
{

del();
}
else if(x=='5')
{
exit(0);
}
else
{
}
}while(x != 16);
getch();
}