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

Department of computer science at Birzeit University offers a set of courses eac

ID: 3844622 • Letter: D

Question

Department of computer science at Birzeit University offers a set of courses each semester. These courses are listed in a file as follows: course name, course id, number ofregistered student, and max number of students. Number of registered students is initialized to zero always. The file that contains the courses’ information is formatted as follows (i.e. sample course file): Each semester, students are required to register a set of courses. The students are listed in a file along with the courses to be registered as follows: student name, student id, courses to be registered (COMP242, COMP336, COMP231…). The file that contains the students’ information is formatted as follows (i.e. sample student file): Course File

Java#COMP231#0#27 Data Structures #COMP2321#0#30 Algorithms#COMP336#0#15 Computer and Programming#COMP142#0#27

Student File

Ahmad Ali#1159999#COMP242#COMP336#COMP231#COMP338 Ali Mahmoud#1169999#COMP142#COMP336#COMP231

Ashraf Hasan #1139999#COMP142#COMP336#COMP231#COMP333#COMP432#COMP338#COMP233

Programming Requirements: 1. Your program should use the concept of struct. Hint: create two structs, one for course and the second for student.

typedef struct { char sName[30]; int stdNo; int NoRegCourses; }student;

typedef struct { char cName[30]; char cNo[10]; int maxRegNo; int currentRegNo; student sList[50]; }course; 2. Your program should use some of string functions, e.g. strlen, strtok. 3. Hint: to convert a string to integer you may use the following function atoi(). Example: int val; char str[20]; strcpy(str, "116987"); val = atoi(str); printf("String value = %s value = %d ", str, val); What to Do: 1. Read the offered courses from the course file into an array of type course. 2. Read the students from the student file, and add the student to the required courses. Before adding a student to any course, you have to make sure that: a. The course is offered by the department (i.e. is available in the course list). For example, Ashraf Hasan want to register COMP333, but it is not offered by the department. b. The student can register for at most 4 courses each semester. c. Number of registered students in each course should not exceed the maximum number of students. For example, if 23 students want to register COMP336, then just the first 15 students should be added to this course. 3. After that, for each course print the list of students.

Explanation / Answer

Here is the psuedo code in c++ , not much time, try to understand using this code

#include <iostream>
#include <cstring>
#include <fstream>
//ifstream infile("thefile.txt");
using namespace std;

typedef struct{
   char sName[30];
   int stdNo;
   int NoRegCourses;
   char *ccname[10];
}student;
typedef struct{
   char cName[30];
   char cNo[10];
   int maxRegNo;
   int currentRegNo;
   student sList[50];
}course;

struct student *cinput(char *str[],char *str1[])
{
    struct student students[];
int i=0,j=0;
k = str.size();
char l[];
while(k--)
{
   j=0;
l = strtok(str,"#");
   while(l!=NULL){
       int z=0;
       printf("%s",l);
       switch(j)
       {
           case 0:
           students[i].sName = l;
           break;
           case 1:
           students[i].stdNo = l;
           break;
           default:
           students[i].ccName[z]= l;
           z++;
           break;
      
       }
  
       l =strtok(NULL,"#");
       j++;
       students[i].NoRegCourses = z;
   }
   i++;
}
}
struct *course cinput(char *str[])
{
    struct course courses[];
int i=0,j=0;
k = str.size();
char l[];
while(k--)
{
   j=0;
l = strtok(str,"#");
   while(l!=NULL){
       printf("%s",l);
       switch(j)
       {
           case 0:
           courses[i].cName = l;
           break;
           case 1:
           courses[i].cNo = l;
           break;
           case 2:
           courses[i].currentRegNo = atoi(l);
           break;
           default:
           courses[i].maxRegNo= atoi(l);
           break;
      
       }
  
       l =strtok(NULL,"#");
       j++;
      
       }
   i++;
}
return courses;
}
void process(course courses[],student students[])
{
    int sk = students.size();
    int ck = courses.size();
    int z=0;
    while(sk--)
    {
        while(ck--)
        {
            int jh = students[sk].ccname.size();
            while(jh--){
                int m= courses[ck].slist.size();
               
                int count=0,counS=0;
                if(count+countS<4 && m<=courses[ck].maxRegNo){
                while(m--) {
                   
                  if(courses[ck].slist[z].stdNo == students[sk].stdNo)
                  {
                      countS++;
                  }
                  else if(strcmp(courses[ck].cNo,students[sk].ccname[jh]))
                  {
                      courses[ck].sList[z] = students[sk];
                      count++;
                      z++;
                      break;
                      //z++;
                  }
              }
                }
                else
                {
                    break;
                }
            }
        }
    }
    while(ck--)
    {
        int jh = courses[ck].slist.size();
        while(jh--){
        print(courses[ck].sList[jh]); // print Student List
        }
    }
}
int main() {
   struct course cc[100];
   struct student ss[100];
   char *student[];char *course[];
   ss=sinput(student); //read from file
   cc = cinput(course);
   process(cc,ss);
   // your code goes here
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote