Question: Write a C program that uses string processing functions to properly format a Comma Separated Values (csv) file of course Information and store them into

Write a C program that uses string processing functions to properly format a Comma Separated Values (csv) file of course Information and store them into an array of structures. Once all data have been formatted and stored, the program should be able to:

a. Add new course

b. Search for course information using either course name or course number as the search key

c. Display all or any course data.

Assume that the CourseInfo structure has been defined as follows:

struct CourseInfo{

int courseID;

char courseName[50];

char courseCode[12];

char Term [6];

};

typedef struct CourseInfo courseInfo; //optional

Example

Fields in the input file are comma separated as follows:

CourseName,Faculty,Subject,Level,Section,Semester,Year

Content of a sample input file:

programming,03,60,141,01,W,2015

programming,03,60,141,30,W,2015

Algebra,03,62,102,02,S,2013

Religion,08,98,938, 20,F,2014

Corresponding field values in the array of structures (after formatting):

CourseID

1

2

3

4

CourseName

PROGRAMMING

PROGRAMMING

ALGEBRA

RELIGION

CourseCode

0360-141-01

0360-141-30

0362-102-02

0898-938-20

Term

W2015

W2015

S2013

F2014

***The program must implement at least the following functions:

loadCourseInfo(): To read all data from input file and format and store them in an array of structures.

displayCourseInfo(): To print a table indicating the course Information. For example:

ID

Name

Code

Term

1

PROGRAMMING

0360-141-01

W2015

2

PROGRAMMING

0360-141-30

W2015

3

ALGEBRA

0362-102-02

S2013

addCourseInfo(): To add a new course. Note that:

- CouseID should be unique and generated automatically by your program (last courseID+1).

- CourseCode is also unique and you cannot have two courses with the same courseCode. So, before adding a course, search for the courseCode to be sure that you have not had it previously

searchCourseInfo(): To search for a course information using courseID or course Name and print the course information if it exists.

**Note:

*Course ID should be unique sequential integers starting from 1 (not from 0).

*Course name must be all capital letters (upper case).

*Course Code should also be unique and store in the format as xxxx-xxx-xx. The first xxxx part indicates faculty code (xx) and subject code (xx). The second xxx part indicates level and the last xx part indicates section number. For example 0450-231-40

*Term should be one character indicating semester (S, F,W) following by 4 digits indicating a year. For example W2012, F2017

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!