Sei sulla pagina 1di 2

Faculty of Engineering and Technology

Computer Science Department


COMP142
Assignment # 4 Spring 2016/2017
Due Date: 31/5/2017 at 11:45 PM

Notes:
1. Submit your assignment through Ritaj only.
2. The assignment should be submitted on the due date, late submission will NOT be accepted for any reason.
3. The assignment is individual effort. Copying the assignment will be treated as a cheating attempt, which
may lead to fail the course.

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 of registered 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):

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

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):

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\n", 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.

Potrebbero piacerti anche