/* Course Number : ISYS 116 Student Name : Jason Gradziel Student Number : 826-135-535 Professors Name : Gene Rychlewski Class Name : Thursday Lab Title : Menu Case Structure */ #include #include #include #include /* Function Prototypes */ void setup(void); void process(void); void wrapup(void); void prtmenu(void); void choose(void); void GPA(void); void lineprt(void); void tabledata(void); /* Function Prototypes - for GPA */ /* Mainline functions */ int setupGPA(); int processGPA(); int wrapupGPA(); /* Subroutine functions */ void titleGPA(); void getnumsubjectsGPA(); void prtheadersGPA(); void prtnumsubjectsGPA(); void prttotalGPA(); void getinputGPA(); void calcsGPA(); void finalGPA(); void prtGPAmsgGPA(); void getyesnoGPA(); /* Function Prototypes - for line print */ /* Mainline functions */ int setupLPRT(); int processLPRT(); int wrapupLPRT(); /* Function Prototypes - for table data */ /* Mainline functions */ int setupTDATA(); int processTDATA(); int wrapupTDATA(); /* Globle Variables */ int choice; /* Global Variables - for GPA */ char fname[16], lname[21], snum[12], //= "___-___-___", ccode[9]; int numsubjt, mark, credits, wmark, num, flag=1; double totalGPA, totalcrdt, gpa; /* Global Variables - for line print */ char alpha; int length; /* Global Variables - for table data */ int total=0; /* Mainline logic */ void main (void) { setup(); process(); wrapup(); } /* Subroutines */ void setup(void) { prtmenu(); choose(); } void process(void) { /* loop to process choice */ while (choice != 0) { switch (choice) { case 1: GPA(); break; case 2: lineprt(); break; case 3: tabledata(); break; case 0: break; default: gotoxy(26,15); printf("Invalid choice - try again"); gotoxy(26,16); printf("Press any key to continue"); getch(); } setup(); } } void wrapup(void) { gotoxy(35,23); printf("D O N E !!"); getch(); } void prtmenu(void) { /* print screen, title & prompt for choice */ clrscr(); gotoxy(26,1); printf("**************************"); gotoxy(26,2); printf("* Sample of Menu Program *"); gotoxy(26,3); printf("**************************"); gotoxy(26,5); printf("Select one of the following"); textcolor(1); gotoxy(30,7); cprintf("1 Calculate GPA average"); textcolor(2); gotoxy(30,8); cprintf("2 Line print"); textcolor(4); gotoxy(30,9); cprintf("3 Table of ASCII Data"); textcolor(5); gotoxy(30,10); cprintf("0 Exit"); } void choose(void) { /* get maenu choice */ gotoxy(26,15); printf("Enter your choice: "); scanf("%d", &choice); } void GPA(void) { flag = 1; while (flag==1) { totalGPA=0; totalcrdt=0; gpa=0; for (int a=0; a<11; a++) snum[a]= ' '; setupGPA(); processGPA(); wrapupGPA(); getyesnoGPA(); } /* clean up */ fflush(stdin); //getch(); clrscr(); } void lineprt(void) { setupLPRT(); processLPRT(); wrapupLPRT(); /* clean up */ fflush(stdin); getch(); clrscr(); } void tabledata(void) { setupTDATA(); processTDATA(); wrapupTDATA(); } /* Subroutines - for GPA */ int setupGPA() { fflush(stdin); titleGPA(); getnumsubjectsGPA(); prtheadersGPA(); prtnumsubjectsGPA(); return 0; } int processGPA() { for(num=0; num 7) numsubjt = 7; } void prtheadersGPA() { clrscr(); titleGPA(); gotoxy(30,6); printf("%s %s %s",fname,lname,snum); gotoxy(10,10); printf("#"); gotoxy(15,9); printf("Course"); gotoxy(16,10); printf("Code"); gotoxy(30,10); printf("Mark"); gotoxy(40,10); printf("Credits"); gotoxy(50,9); printf("Weighted"); gotoxy(51,10); printf("Mark"); gotoxy(10,11); printf("="); gotoxy(15,11); printf("======"); gotoxy(30,11); printf("===="); gotoxy(40,11); printf("======="); gotoxy(51,11); printf("===="); } void prtnumsubjectsGPA() { for (num=0; num 79) { gotoxy(25,num+16); printf("Congratulations!...You have Honours!"); } else { gotoxy(25,num+16); printf("Passing!...Keep up the good work."); } } void getyesnoGPA() { int flag2=1; while (flag2==1) { char quit; printf("\n\n\tDo you want to quit?(Y/N) "); quit=getch(); if (quit == 'Y' || quit == 'y') { printf("\n\tBye Bye!"); flag = 0; flag2=0; delay(500); //getch(); } else if (quit == 'N' || quit == 'n') { printf("\n\tO.K."); delay(500); flag2=0; //getch(); } else { printf("\n\tThat is incorrect."); delay(500); //getch(); } } } /* Subroutines - for line print */ int setupLPRT() { clrscr(); printf("\n\t\tLine Print Program\n\n"); printf("\nEnter in a character to be displayed : "); alpha = getche(); //getch(); printf("\nEnter in the number of times (1 to 80) : "); scanf("%d",&length); printf("\n\n\n"); return 0; } int processLPRT() { for (int times=0; times