You are required to develop a complete C program that helps

You are required to develop a complete C program that helps a lecturer to manage student records. Each student\'s record contains information like student identification number, name, course major and CGPA, and they are stored in a text file. The software reads students\' information from a file, and allows the lecturer to do the following: print the list of student records, add new student record (appended at the end of the record), update information on existing record, sort student records (according to student identification number) into ascending order, save the updated student records in a file. In updating student\'s details, one needs to search for the student record from the existing records. In this application, linear search and binary search are to be implemented. On the other hand, selection sort and insertion sort algorithms are to be implemented to sort data. Note that two for each sorting and searching algorithms are used in the program. Your program should select the suitable algorithms accordingly. For example, if the lecturer opts to search for a student details from a medium size of an unsorted student records, in this case binary search is more preferable over linear search for faster time complexity. However, binary search requires input data to be sorted. In selecting sorting algorithm, the program might want to consider the randomness of the data. A sample output is given below:

Solution

# include <stdio.h>

# include <stdlib.h>

void Menu();

void New_Student();

void Delete_Student();

void Export_Profile();

struct element

{

char id[20];

char name[20];

char coursemajor[20];

double cgpa;

  

}

profile;

int main(void)

{ //The program will continue running until option 4 selected   

int a;

for (a = 0; ; a++)

{

Menu();

}

return 0;

}

void Menu() //Main Menu to select option

{

int n;

printf(\"\ **********************************************\");

printf(\"\ MAIN MENU-Student INFORMATION SYSTEM\");

printf(\"\ **********************************************\");

printf(\"\ 1. Add profile Student Profile\");

printf(\"\ 2. Delete Student Profile\");

printf(\"\ 3. Export All Profiles to \'output.txt\'\");

printf(\"\ 4. Exit\");

printf(\"\ **********************************************\");

printf(\"\ Please enter your option< 1 / 2 / 3 / 4 >: \");

scanf(\"%d\", &n);

switch (n)

{

case 1:

New_Student();

break;

case 2:

Delete_Student();

break;

case 3:

Export_Profile();

break;

case 4:

printf(\"\ *** Thanks for using the program! Goodbye. ***\");

exit(0);

break;

default:

printf(\"\ Error! Wrong Number is Entered\ Please Try Again\");

break;

}

}

void New_Student() //Add New Student Profile

{

int x;

struct element profile;

printf(\"\ ===Add New Student Profile===\");

printf(\"\ \ Please enter the following Student information.\");

printf(\"\ \ Student ID: \");

scanf(\"%s\", &profile.id);

printf(\"Name\\t: \");

fflush(stdin);

fgets(profile.name,20, stdin);

for(x=0 ; x<20 ; x++)

{

if(profile.name[x] == \'\ \')

  profile.name[x] = \'\\0\';

}

printf(\"Course Major\\t: \");

scanf(\"%s\", &profile.coursemajor);

printf(\"CGPA\\t: \");

scanf(\"%s\", &profile.cgpa);

printf(\"\ SYSTEM: New Student Profile is Added Successfully.\");

}

void Delete_Student() //Delete Student Profile

{

FILE* fRead, *fWrite;

char* TextFile;

char c;

int Delete_Id, temp = 1;

TextFile = \"output.txt\";

fRead = fopen(TextFile, \"r\");

c = getc(fRead);

while (c != EOF)

{

printf(\"%c\", c);

c = getc(fRead);

}

rewind(fRead);

printf(\"\ Delete Student with ID: \");

scanf(\"%d\", &Delete_Id);

Delete_Id = Delete_Id + 1;

fWrite = fopen(\"copy.c\", \"w\");

c = getc(fRead);

while (c != EOF)

{

c = getc(fRead);

if (c == \'\ \')

temp++;

if (temp != Delete_Id)

{

putc(c, fWrite);

}

}

fclose(fRead);

fclose(fWrite);

remove(TextFile);

rename(\"copy.c\", TextFile);

printf(\"\ The contents of file after being modified are as follows:\ \");

fRead = fopen(TextFile, \"r\");

c = getc(fRead);

while (c != EOF)

{

printf(\"%c\", c);

c = getc(fRead);

}

fclose(fRead);

}

void Export_Profile() //Export Student Profile to Text

{

struct element profile;

FILE* fPtr;

fPtr=fopen(\"output.txt\",\"w\");

FILE* fPtr1;

fPtr1=fopen(\"output.txt\",\"a+\");

if (fPtr == NULL)

printf(\"Error in opening file\ \");

if (fPtr1 == NULL)

printf(\"Error in opening file\ \");

fprintf(fPtr,\"%10s %10s %10s %10s %10s\",\"Student\",\"ID\",

\"Name\",\"CourseMajor\",\"CGPA\");

fprintf(fPtr1,\"\ %10s %10s %10s %10s %10s\", profile.id, profile.name,

profile.coursemajor, profile.cgpa);

printf(\"\ %10s %10s %10s %10s %10s\", \"Student\", \"ID\", \"Name\",

\"CourseMajor\", \"CGPA\");

printf(\"\ %10s %10s %10s %10s %10s\", profile.id,

profile.name, profile.coursemajor, profile.cgpa);

printf(\"\ SYSTEM: All Student profile have been exported to output.txt file\");

fclose(fPtr);

fclose(fPtr1);

}

}

}

 You are required to develop a complete C program that helps a lecturer to manage student records. Each student\'s record contains information like student iden
 You are required to develop a complete C program that helps a lecturer to manage student records. Each student\'s record contains information like student iden
 You are required to develop a complete C program that helps a lecturer to manage student records. Each student\'s record contains information like student iden
 You are required to develop a complete C program that helps a lecturer to manage student records. Each student\'s record contains information like student iden
 You are required to develop a complete C program that helps a lecturer to manage student records. Each student\'s record contains information like student iden

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site