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

Could I get a an example of the code for the search, delete, and insert function

ID: 3851320 • Letter: C

Question

Could I get a an example of the code for the search, delete, and insert functions? Thanks!

Declarations for Project #9 struct student student's ID number (key) unsigned long number char name [25] student's name points on Exam #1 unsigned short exam1 points on Exam #2 unsigned short exam2 points on homework unsigned short hwi total points (exams hw) unsigned short total percent of available (rounded) unsigned short per cent i struct table unsigned short capacity number of elements in table number of students in table unsigned short count i unsigned short available total points available pointer to array of students struct student memory Function search Purpose locate and return a pointer to a student, if the student is present in the table Arguments pointer to table of students identification number of student to be located pointer to pointer to student Return value 1 (true) if student located 0 (false) otherwise int search struct table*, unsigned long, struct student** Function delete Purpose delete a student from the table, if the student is present in the table Arguments pointer to table of students identification number of student to be deleted Return value 1 (true) if student deleted. 0 (false) otherwise int delete struct table*, unsigned long

Explanation / Answer

studentinfo.cpp

----------------------

#include <iostream>
#include<string>
using namespace std;
struct student
{
   unsigned long number;
   char name[25];
   unsigned short exam1;
   unsigned short exam2;
   unsigned short hw;
   unsigned short total;
   unsigned short percent;
};
struct table
{
   unsigned short capacity;
   unsigned short count;
   unsigned short availables;
   struct table*memory;
};
bool search(struct table*,unsigned long,struct student **);
bool delete2(struct table*,unsigned long);
bool insert(struct table*,unsigned,char*,int,int,int);
int main()
{
int opt;
int n=0;
struct student obj,*obj3;
struct table obj2;
char str[25];
while(1)
{
cout<<"---------------------------"<<endl;
cout<<"*********MENU**************"<<endl;
cout<<"---------------------------"<<endl;
cout<<"1.Insert New Student Information"<<endl;
cout<<"2.Deletion of Student Information"<<endl;
cout<<"3,Searching of Student Information"<<endl;
cout<<"4.Exit"<<endl;
cout<<"Select Any Option";
cin>>opt;
switch(opt)
{
   case 1:
       cout<<"Enter The Student Name:"<<endl;
       cin>>obj.name;
       cout<<"Enter The Student Id: "<<endl;
       cin>>obj.number;
       cout<<"Enter The Exam Points1:"<<endl;
       cin>>obj.exam1;
       cout<<"Enter The Exam Points2:"<<endl;
       cin>>obj.exam2;
       cout<<"Enter the homework:"<<endl;
       cin>>obj.hw;
       insert(&obj2,obj.number,obj.name,obj.exam1,obj.exam2,obj.hw);
       break;
       case 2:
       cout<<"Enter The Student Information Like Student id: To Delete"<<endl;
       cin>>obj.number;
       delete2(&obj2,obj.number);  
       break;
       case 3:
       cout<<"Enter The Student Information Like Student id: To Search"<<endl;
       cin>>obj.number;
       search(&obj2,obj.number,&obj3);
       break;
       case 4:
       exit(0);
       default:
       cout<<"Invalid Option";
}
}  
}
bool insert(struct table *obj2,unsigned id,char *name2,int examm1,int examm2,int hw2)
{
struct student *memory;  
if((memory->name!=name2)&&(obj2->capacity>0))
{
//memory->exam2=examm2;
memory->hw=hw2;
obj2->count++;
return true;  
}
else
{
return false;
}
}
bool search(struct table *obj2,unsigned long id,struct student **obj)
{
struct student *memory;  
for(int i=0;i<obj2->count;i++)
{
if(memory->number==id)
{
return true;
}
memory->number;
}
return false;
}

bool delete2(struct table*obj2,unsigned long id)
{
struct student *memory;  
for(int i=0;i<obj2->count;i++)
{
if(memory->number==id)
{
  
return true;
}
memory->number;
}
return false;
}