Question: #include #include #include / / / / / / / / / / / / / / / / / / / / / /
#include
#include
#include
MACROS: CONSTANTS
DATA STRUCTURES
GLOBAL VARIABLES
place to store course information
struct CourseNode coursecollection NULL;
typedef enum
SER,
EGR,
CSE,
EEE
SER EGR CSE EEE
SUBJECT;
typedef struct CourseNode
SUBJECT subName;
int courseNum;
char teacher;
int hours;
struct CourseNode next;
CourseNode;
int totalCreditsstruct CourseNode head
int credits ;
struct CourseNode tmp head;
whiletmp NULL
credits tmp hours;
tmp headnext;
return credits;
char subName
void courseinsertstruct CourseNode head, int subNum, int courseNumber, int credHours, char prof
struct CourseNode newClass current;
newClass struct CourseNodemallocsizeofCourseNode;
newClass subName subNum;
newClass courseNum courseNumber;
newClass hours credHours;
strcpynewClassteacher, prof;
ifhead NULL headcourseNum newClasscourseNum
newClassnext head;
head newClass;
else
current head;
whilecurrent next NULL && currentnextcourseNum newClasscourseNum
current currentnext;
newClassnext currentnext;
currentnext newClass;
void coursedropstruct CourseNode headRef, int num
CourseNode tmp headRefprev;
iftmp NULL && tmpcourseNum num
headRef tmpnext;
freetmp;
return;
whiletmp NULL && tmpcourseNum num
prev tmp;
tmp tmpnext;
iftmp NULL
return;
prevnext tmpnext;
freetmp;
tmp NULL:
void scheduleprint
struct CourseNode tmp;
whiletmp NULL
switchtmpsubName
case :
printfSER d d s tmpcourseNum,tmphours,tmpteacher;
break;
case :
printfEGR d d s tmpcourseNum,tmphours,tmpteacher;
break;
case :
printfCSE d d s tmpcourseNum,tmphours,tmpteacher;
break;
case :
printfEEE d d s tmpcourseNum,tmphours,tmpteacher;
break;
default:
printfYou have no classes in your schedule.";
break;
tmp tmp next;
void branchingchar option;
main entry point. Starts the program by displaying a welcome and beginning an
input loop that displays a menu and processes user input. Pressing q quits.
int main
char inputbuffer;
printf
Welcome to ASU Class Schedule
;
do
printf
Menu Options
;
printf
;
printfa: Add a class
;
printfd: Drop a class
;
printfs: Show your classes
;
printfq: Quit
;
printf
Total Credits: d
totalCreditscoursecollection;
printfPlease enter a choice ;
scanfc &inputbuffer;
branchinginputbuffer;
while inputbuffer q;
freecoursecollection;
return ;
takes a character representing an inputs menu choice and calls the appropriate
function to fulfill that choice. display an error message if the character is
not recognized.
void branchingchar option
int classNum;
int subjectNum;
int courseCred;
int n;
char teacher;
switch option
case a:
printfAdd class subject SER: EGR: CSE: EEE: :;
scanfd &subjectNum;
ifsubjectNum subjectNum
printfChoose between the given selection please!
Pick class: ;
scanfd
&subjectNum;
printfWhat are the numbers that follow the subject? Ex: SER : ;
scanfd &classNum;
printfHow many credits is this class?: ;
scanfd &courseCred;
printfWho teaches this class?: ;
scanfs &teacher;
courseinsert&coursecollection,subjectNum,classNum,courseCred,teacher;
break;
case d:
printfenter the course number for the class you would like to drop: ;
scanfd &n;
coursedrop&coursecollection, n;
break;
case s:
scheduleprint;
break;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
