In this assignment, you are going to write a C program that reads, processes and displays records of students registered
Posted: Fri May 20, 2022 10:41 am
In this assignment, you are going to write a C program that reads, processes and displays records of students registered to courses in a university. Your program reads two input files. Each file contains records of students registered to a particular course. Your program produces an output file which contains information about list of students registered to both of the courses intersection) or either of the courses (union). List of students registered to each course is provided as a text file. Getting to know input file: A sample input file (course1.txt) is given as follows: Ogrenci No; Ogrenci;Program;Sinif;Email;Status 10000000000;EDA NUR YILMAZ;Computer Engineering;4; [email protected]; 10000000010; FEYZA NUR DUMAN; Computer Engineering;2; [email protected]; 20000000010; GOKHAN YAMAC; Computer Engineering;2; [email protected]; 30000000030;CEREN AYDINLI;Computer Engineering;2;[email protected]; 30000000010;DURU YAMAC; Computer Engineering; 3; [email protected]; 40000000010;SEVIL TERZI;Computer Engineering;2; [email protected];W 50000000010; EREN AYDIN; Computer Engineering;2;[email protected]; 50000000020;YAMAC YILMAZ;Computer Engineering;2;[email protected]; 60000000020;EDANUR YILMAZ; Computer Engineering;2;[email protected]; 70900900010; GOKHAN YAMAC; Computer Engineering;2;[email protected]; Another sample input file (course2.txt) is given as follows: Ogrenci No; Ogrenci;Program; Sinif; Email;status 70000000010; GOKHAN YAMAC; Computer Engineering;2;[email protected]; 10000000000;EDA NUR YILMAZ; Computer Engineering;4; [email protected]; 60000000020;EDANUR YILMAZ;Computer Engineering;2;[email protected]; 11000000010; FEYZA DUMANLI;Computer Engineering;2; [email protected]; 31000000030;CEREN AYDIN;Computer Engineering;2; [email protected]; 31000000010;DURU AMAC; Computer Engineering; 3; [email protected]; 80000000010; YESIM KAMA;Computer Engineering;2;[email protected]; 50000000010;EREN AYDIN; Computer Engineering;2;[email protected]; NUR
. The first line of the input file is a header line which includes title of each column of the data file. Each of the remaining lines includes a record of a student registered to the course. • Ogrenci No o 11-digits Student ID Students are uniquely recognized by their ID. Ogrenci O Name & surname (written in all uppercase letters) Name of a student might include more than one word but surname is always a single word at the end of name & surname. o Assume that there are one or more space characters between words in name & surname Regarding EDA NUR YILMAZ, YILMAZ is the surname and there are two names, which are EDA and NUR. Regarding EDANUR YILMAZ, YILMAZ is the surname and there is a single name, which is EDANUR. Program o Program of the student • Sinif Year of the student Email Email address (written in all lowercase letters) Students are uniquely recognized by their email addresses. • Status o Status showing whether the student withdrew the course o W if the student withdrew the course. Otherwise, it is empty. Assume that the number of students in a course is at most 500. How to run the program: Your program shall be executed from the command line as below using 4 command line arguments: >hw.exe <InputFileName1> <InputFileName2> <OutputFileName> <Operation> where each command line argument is described as below: <InputFileName> : 1st argument is name of the first input file, i.e. name of the file containing records of students registered to the first course. <InputFileName2> : 2nd argument is name of the second input file, i.e. name of the file containing records of students registered to the second course. <OutputFileName>: 3rd argument is name of output file. :
<Operation>: 4th argument is the operation we would like to have. If it is -i, the operation is intersection and the output file contains information about list of students registered to both of the courses. If it is -u, the operation is union and the output file contains information about list of students registered to either of the courses. What the program is expected to do: Your program is supposed to do the following tasks: 1. Read the first input file so that store ID, name, surname, program, year, email and status for each student registered to the first course. 2. Read the second input file so that store ID, name, surname, program, year, email and status for each student registered to the second course. 3. Find the list of students whose information is to be written to the output file. If the operation is intersection, then find the list of students registered to both the first course and the second course. You could use ID or email fields to check whether two students are the same or not. o If the operation is union, then find the list of students registered to either the first course or the second course. Note that, in this list, each student must appear only once. You could use ID or email fields to check whether two students are the same or not. 4. Write the information about the list of students found in the previous step to the output file in a sorted way. o The students are sorted according to their surnames. If surnames of the students are the same, they are sorted according to their names. o if both surnames and names of the students are the same, they are sorted according to their email addresses. Sample Runs: Sample run 1: > hw.exe course1.txt course2.txt course_1_2_intersect.txt -i The content of course_1_2_intersect.txt is as follows: 11: AYDIN, EREN, Computer Engineering, 2, [email protected] 2: YAMAC, GOKHAN, Computer Engineering, 2, [email protected] 3: YILMAZ, EDA NUR, Computer Engineering, 4, [email protected] 4: YILMAZ, EDANUR, Computer Engineering, 2, [email protected]
Sample run 2 > hw.exe course 1.txt course2.txt course_1_2_union.txt -u The content of course_1_2_union.txt is as follows: H: 1: AMAC, DURU, Computer Engineering, 3, [email protected] 2: AYDIN, CEREN, Computer Engineering, 2, [email protected] 3: AYDIN, EREN, Computer Engineering, 2, [email protected] 4: AYDINLI, CEREN, Computer Engineering, 2, [email protected] 5: DUMAN, FEYZA NUR, Computer Engineering, 2, [email protected] 6: DUMANLI, FEYZA NUR, Computer Engineering, 2, [email protected] 7: KAMA, YESIM, Computer Engineering, 2, [email protected] 8: TERZI, SEVIL, Computer Engineering, 2, [email protected] 9: YAMAC, DURU, Computer Engineering, 3, [email protected] 10: YAMAC, GOKHAN, Computer Engineering, 2, [email protected] 11: YAMAC, GOKHAN, Computer Engineering, 2, [email protected] 12: YILMAZ, EDA NUR, Computer Engineering, 4, [email protected] 13: YILMAZ, EDANUR, Computer Engineering, 2, [email protected] 14: YILMAZ, YAMAC, Computer Engineering, 2, [email protected] Format of the output file Each line of the output file contains the information about each student in the following format: <Line Number>: <Surname>, <Name(s)>, <Program>, <Year>, <Email> Note that when there are multiple names of a student, they are separated by a single space in the output file. Hints You can use any available string sorting algorithm in your source code in the literature, but your source code is expected to be comprised by only 1 source file (so all your functions including the sorting function should be in the same file). In this homework, you are mainly expected to use your skills from Chapter 8 Strings of the book. Check out string.h library functions. Check also character functions available in ctype.h. You may also consider using fgets, fputs functions under stdio.h, if applicable to your solution.