Assignment Description Write a C program for keeping a cours

Assignment Description:

Write a C++ program for keeping a course list for each student in a college. Information about each student should be kept in an object that contains the student id (four digit integer), name (string), and a list of courses completed by the student.

The course taken by a student are stored as a linked list in which each node contain course name (string such as CS41, MATH10), course unit (1 to 4) and the course grade (A,B,C,D,F).

The program provides a MENU with choices that include adding a student record, deleting a student record, adding a single course record to a student’s record, deleting a single course record from a student’s record, and print a student’s record to a screen.

A student record should include a GPA (Grade Point Average) when display on the screen. The GPA is calculated by following formula:

When the user is through with the program, the program should store the records in a file. The next time the program is run, the records should be read back out of the file and the list should be reconstructed

You will need to implement a List container to hold a list of student records, each of which has a List container as its member. Note that no duplicate items should be permitted in either (student and course) List container.

Develop a test driver program that allow options to add, remove, and display student records and the course list of each student.

Use the class template technique (in C++) to implement a List ADT that could be used for both student list and the course list..

To calculate G.P.A. for one term:

Multiply the point value of the letter grade (A=4, B=3, C=2, D=1, F=0) by the number of credit hours. The result is the grade points (quality points) earned.

Total the credit hours for the student; total the quality points for the student.

Divide the total quality points by the total credit hours.

Solution


#include<stdio.h>
struct student
{
    int rollno;
    char name[30];
    float mark;
}stud;
//    FUNCTION TO INSERT RECORDS TO THE FILE
void insert()
{
    FILE *fp;
    fp=fopen(\"Record\",\"a\");
    printf(\"Enter the Roll no :\");
    scanf(\"%d\",&stud.rollno);
    printf(\"Enter the Name      :\");
    scanf(\"%s\"&stud.name);
    printf(\"Enter the mark      :\");
    scanf(\"%f\",&stud.mark);
    fwrite(&stud,sizeof(stud),1,fp);
    fclose(fp);
}
//    FUNCTION TO DISPLAY RECORDS
void disp()
{
    FILE *fp1;
    fp1=fopen(\"Record\",\"r\");
    printf(\"\ Roll Number\\tname\\tMark\ \ \");
    while(fread(&stud,sizeof(stud),1,fp1));
    printf(\"%d\\t\\t%s\\t%.2f\ \",stud.rollno,stud.name,stud.mark);
    fclose(fp1);
}
//    FUNCTION TO SEARCH THE GIVEN RECORD
void search()
{
    FILE *fp2;
    int r,s,avl;
    printf(\"\ Enter the Roll no you want to search :\");
    scanf(\"%d\",&r);
    avl=avlrollno(r);
    if(avl==0)
    printf(\"Roll No %d is not avilable in the file\ \");
    else
    {
        fp2=fopen(\"Record\",\"r\");
        while(fread(&stud,sizeof(stud),1,fp2))
        {
            s=stud.rollno;
            if(a==r)
            {
                printf(\"\ Roll no = %d\",stud.rollno);
                printf(\"\ Name    = %s\"stud.name);
                printf(\"\ Mark    = %.2f\",stud.mark);
            }
        }
        fclose(fp2);
    }
}
//    FUNCTION TO DELETE A RECORD


void deletef()
{
    FILE *fp;
    FILE *fpt;
    int r,s;
    printf(\"Enter the Roll no you want to delete :\");
    scanf(\"%d\",&r);
    if(avlrollno(r)==0)
    printf(\"Roll no %d is not available in the file\ \");
    else
    {
        fpo=fopen(\"Record\",\"r\");
        fpt=fopen(\"TempFile\",\"w\");
        while(fread(&stud,sizeof(stud),1,fpo))
        {
            a=stud.rollno;
            if(s!=r)
            fwrite(&stud,sizeof(stud),1,fpt);
        }
        fclose(fpo);
        fclose(fpt);
        fpo=fopen(\"Record\",\"w\");
        fpt=fopen(\"TempFile\",\"r\");
        while(fread(&)stud,sizeof(stud),1,fpt)
        fwrite(&stud,sizeof(stud),1,fpo);
        printf(\"\ RECORD DELETE\ \");
    }
    fclose(fpo);
    fclose(fpt);
}
//    FUNCTION TO UPDATE THE RECORD
void update()
{
    int avl;
    FILE *fpt;
    FILE *fpo;
    int s,r,ch;
    printf(\"enter roll number to update\");
    scanf(\"%d\",&r);
    avl=avlrollno(r);
    if(avl==0)
     {
        printf(\"roll number %d is not Available in the file\",r);
     }
    else
     {
        fpo=fopen(\"Record\",\"r\");
        fpt=fopen(\"TempFile\",\"w\");
        while(fread(&stud,sizeof(stud),1,fpo))
        {
            s=stud.rollno;
            if(s!=r)
            fwrite(&stud,sizeof(stud),1,fpt);
            else
             {
                printf(\"\ \\t1_UPDATE THE NAME OF ROLL NUMBER %d\",r);
                printf(\"\ \\t1_UPDATE THE MARK OF ROLL NUMBER %d\",r);
                printf(\"\ \\t1_UPDATE BOTH NAME AND MARK OF ROLL NUMBER %d\",r);
                PRINTF(\"\\N\\N eNTER YOUR CHOICE\");
                scanf(\"%d\",&ch);
                switch(ch)
                {
                    case 1:
                    printf(\"Enter Name : \");
                    scanf(\"%d\",stud.name);
    `                break;
                    case 2:
                    printf(\"Enter Mark : \");
                    scanf(\"%d\",&stud.mark);
                    break;
                    case 3:
                    printf(\"Enter Name and Mark: \");
                    scanf(\"%d\",stud.name,&stud.mark );
                    break;
                    default:
                    printf(\"Invalid Selection\");
                    break;
                }
                fwrite(&stud,sizeof(stud),1,fpt);
            }
        }   
        fclose(fpo);
        fclose(fpt);
        fpo=fopen(\"Record\",\"w\");
        fpt=fopen(\"TempFile\",\"r\");
        while(fread(&stud,sizeof(stud),1,fpt))
        {
            fwrite(&stud,sizeof(stud),1,fpo);
        }
        fclose(fpo);
        fclose(fpt);
        printf(\"RECORD UPDATED\");
    }
}
/* FUNCTION TO SORT THE RECORD */
void sort()
    {
        int a[20],count=0,i,j,t,c;
        FILE *fpo;
        fpo=fopen(\"Record\",\"r\");
        while(fread(&stud,sizeof(stud),1,fpo))
        {
            a[count]=stud.rollno;
            count++;
        }
        c=count;
        for(i=0;i<count-1;i++)
        {
            for(j=i+1;j<count;j++)
            {
                if(a[i]>a[j])
                {
                    t=a[i];
                    a[i]=a[j];
                    a[j]=t;
                }
            }
        }
        printf(\"Roll no.\\tName\\t\\tMar\ \ \");
        count=c;
        for(i=0;i<count;i++)
        {
            rewind(fpo);
            while(fread(&stud,sizeof(stud),1,fpo))
            {
                if(a[i]==stud.rollno)
                printf(\"\ %d\\t\\t %s \\t\\t %2f\",stud.name,stud.mark);
            }
//    FUNCTION TO CHECK GIVEN ROLL NO IS AVAILABLE //
int avLrollno(int rno)
{
    FILE *fp;
    int c=0;
    fp=fopen(\"Record\",\"r\");
    while(!feof(fp))
    {
        fread(& NAME   :shahul rollno:46 stud,sizeof(stud),1,fp);
        if(rno==stud.rollno)
        {
            fclose(fp);
            return 1;
        }
    }
    fclose(fp);
        return 0;
}
//FUNCTION TO CHECK THE FILE IS EMPTY OR NOT
int empty()
{
int c=0;
FILE *fp;
fp=fopen(\"Record\",\"r\");
while(fread(&stud,sizeof(stud),1,fp))
c=1;
fclose(fp);
return c;
}
// MAIN PROGRAM
{
int c,emp,empty();
do
{
printf(\"\ \\t---Select your choice---------\ \");
printf(\"\ \\t1. INSERT\ \\t2.DISPLAY\ \\t3. SEARCH\");
printf(\"\ \\t4. DELETE\ \\t5.UPDATE\ \\t6.SORT\");
printf(\"\ \\t7. EXIT\");
printf(\"\ \ ------------------------------------------\ \");
printf(\"\ Enter your choice:\"0;
    scanf(\"%d\",&c);
    printf(\"\ \");
    switch(c)
    {
        case 1:
            insert();
            break;
        case 2
            emp=empty();
            if(emp==0)
            printf(\"\ The file is EMPTY\ \");
            else
            disp();
            break;
        case 3:
            search();
            break;
        case 4:
            delete();
            break;
        case 5:
            update();
            break;
        case 6:
            emp=empty();
            ifemp==0()
            printf(\"\ The file is EMPTY\ \");
            else
            sort();
            break;
        case 7:
            exit(0);
        default:
            printf(\"\ Your choice is wrong\ Please try again...\ \");
            break;

        }
    }while(c!=7);
}

Assignment Description: Write a C++ program for keeping a course list for each student in a college. Information about each student should be kept in an object
Assignment Description: Write a C++ program for keeping a course list for each student in a college. Information about each student should be kept in an object
Assignment Description: Write a C++ program for keeping a course list for each student in a college. Information about each student should be kept in an object
Assignment Description: Write a C++ program for keeping a course list for each student in a college. Information about each student should be kept in an object
Assignment Description: Write a C++ program for keeping a course list for each student in a college. Information about each student should be kept in an object

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site