hey I am writing a program for a student management system. I need help with putting it in modules and placing functions in it. structures etc....
realmckoy89 0 Newbie Poster
realmckoy89 0 Newbie Poster
here is my program:
#include <stdio.h> //Standard Input/Output Library
#include <conio.h> //Input/OutputLibrary
#include <stdlib.h> //Standard Library
#include <windows.h> //WinApi header file
#include <string.h> //String
#include <process.h> //Process
#include <ctype.h> //C Type
float Final_Score1, Course_Work, Exam;
short int activity;
char position [60];
char conduct;
int Form, comment, Surname, Christian, Subject, See;
int Dyear, Dabsent, Slate, Dpresent;
int a[50],n,sum=0,I;
float avg;
void menu ();
int main (void)
{
//Internal Speaker Beeping
Beep(10,350);//587 hertz (C5) for 350 milliseconds
Sleep(1); //2 milliseconds delay
puts("\a");
printf("\n");
textcolor(12);
gotoxy(25,2);
cprintf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n");
gotoxy(25,3);
cprintf("³ KINGSWAY HIGH SCHOOL ³\n");
textcolor(14);
gotoxy(25,4);
cprintf("³ ³\n");
textcolor(14);
gotoxy(25,5);
cprintf("³ Reporting System ³\n");
textcolor(14);
gotoxy(25,6);
cprintf("³ ³\n");
textcolor(12);
gotoxy(25,7);
cprintf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ\n\n");
//CALL BY MENU
menu ();
getch (); //pause screen
} //end main
void menu ()
{
int input;
//Software Information
textcolor(4);
gotoxy(25,10);
cprintf(" GREAT REPORTER v 1.01");
textcolor(14);
gotoxy(17,14);
cprintf(" [This Program is coded by Michael Mckoy]");
textcolor(4);
gotoxy(21,16);
cprintf(" Computer Science Unit 2 IA");
gotoxy(21,18);
cprintf(" Email: [email]real_mckoy_89@live.com[/email]");
gotoxy(24,20);
cprintf(" Contact(Mob.): 1876-416-3695\n");
textcolor(2);
gotoxy(24,22);
cprintf(" [Press ENTER]");
getch ();
//Menu Options
printf("\n\n\t\tÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n");
printf("\t\t³\t\t MAIN MENU ³\n");
printf("\t\tÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ\n\n");
gotoxy(18,28);
cprintf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n");
textcolor(14);
gotoxy(18,29);
cprintf("³ TO LOGOUT PRESS 0 ³\n");
textcolor(2);
gotoxy(18,30);
cprintf("³ STUDENT GRADES 1 ³\n");
textcolor(14);
gotoxy(18,31);
cprintf("³ FORM TEACHERS 2 ³\n");
textcolor(2);
gotoxy(18,32);
cprintf("³ ACCESS STUDENT GRADES 3 ³\n");
textcolor(14);
gotoxy(18,33);
cprintf("³ INDEPENDENT CALCULATIONS 4 ³\n");
textcolor(2);
gotoxy(18,34);
cprintf("³ STUDENT INFORMATION 5 ³\n");
textcolor(14);
gotoxy(18,35);
cprintf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ\n\n");
textcolor(LIGHTGREEN);
gotoxy(27,37);
cprintf(" Please Choose an Operation: ");
scanf("%d", &input);
while(input != 0) { //Terminates if zero
switch (input) {
case 1:
printf("\n\n");
printf("\t\tÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n");
printf("\t\t³\t RADING SYSTEM ³\n");
printf("\t\tÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ\n\n");
//STUDENT'S NAME
textcolor(LIGHTRED);
gotoxy(28,44);
cprintf(" Enter Student Name: ");
scanf("%s%s", &Christian, &Surname);
printf("\n_____________________________________________________________________\n");
//SUBJECT
printf("\t\t\t\t\nEnter Subject: ");
scanf("%s", &Subject);
//GRADING SCHEME
printf("\n_____________________________________________________________________\n");
printf("Score\t\tGrade\n\n");
printf("86 - 100 A\n");
printf("71 - 85 B\n");
printf("55 - 70 C\n");
printf("45 - 54 D\n");
printf("0 - 44 E\n\n\n");
printf("Grading Scheme :: A = Distinction, B = Credit, C = Pass, D = Week, E = Fail\n\n");
printf("_____________________________________________________________________\n");
printf("\nEnter Student's Course Work Score:\t");
scanf("\n%f", &Course_Work);
printf("Enter Student's Exam Score:\t\t");
scanf("\n%f", &Exam);
Final_Score1 = 40 * Course_Work / 100 + 60 * Exam / 100;
printf("\nFinal Score is:\t\t\t\t%.1f%",Final_Score1);
printf("\n_____________________________________________________________________\n\n");
if(Final_Score1 >= 86)
printf("Final Grade is:\t\t\t\tA\n");
else
if(Final_Score1 >= 71)
printf("Final Grade is:\t\t\t\tB\n");
else
if(Final_Score1 >= 55)
printf("Final Grade is:\t\t\t\tC\n");
else
if(Final_Score1 >= 44)
printf("Final Grade is:\t\t\t\tD\n");
else
if(Final_Score1 >= 0)
printf("Final Grade is:\t\t\t\tE\n");
printf("_______________________________________________________________________\n\n");
getch ();
//TEACHERS COMMENT ON STUDENT
printf("\n1 A focused student");
printf("\n2 A high standard of performance");
printf("\n3 A hardworking and capable student");
printf("\n4 Works consistently and is making progress");
printf("\n5 Tries hard to do well");
printf("\n6 Works accurately");
printf("\n7 Attends to details");
printf("\n8 Expresses himself/herself very well");
printf("\n9 Oral skills well developed");
printf("\n10 Does well in practical work");
printf("\n11 Always prepared for class");
printf("\n12 Does well in drawing");
printf("\n13 With greater application work should improve");
printf("\n14 Must pay attention to theory");
printf("\n15 Shows interest and is making progress");
printf("\n16 Does not express ideas effectively");
printf("\n17 Finds the subject difficult");
printf("\n18 Should try to be competent in all aspects of the foreign language");
printf("\n19 Has difficulty with exams");
printf("\n20 Too often absent from class");
printf("\n21 Practical assignment not completed");
printf("\n22 Shows little interest");
printf("\n23 Penmanship weak");
printf("\n24 Test and/or assignment not done");
printf("\n25 Needs to read more widely");
printf("\n26 Needs to be punctual for class");
printf("\n27 Minimum effort shown");
printf("\n28 Poor attitude to work");
printf("\n29 Much too talkative");
printf("\n30 Needs to pay attention in class");
printf("\n31 Often underprepared for class");
printf("\n32 A noted drop in performance");
printf("\n33 Lack of text(s) hampers progress");
printf("\n34 Needs extra help\n");
printf("______________________________________________________________________\n");
printf("\n Enter Comment Number:\t\t\t");
scanf("%d", &comment);
if(comment == 1)
{ printf("\nA focused student\n");
}
else
if(comment == 2)
{ printf("\nA high standard of performance\n");
}
else
if(comment == 3)
{ printf("\nA hardworking and capable student\n");
}
else
if(comment == 4)
{ printf("\nWorks consistently and is making progress\n");
}
else
if(comment == 5)
{ printf("\nTries hard to do well\n");
}
else
if(comment == 6)
{ printf("\nWorks accurately\n");
}
else
if(comment == 7)
{ printf("\nAttends to details\n");
}
else
if(comment == 8)
{ printf("\nExpresses himself/herself very well\n");
}
else
if(comment == 9)
{ printf("\nOral skills well developed\n");
}
else
if(comment == 10)
{ printf("\nDoes well in practical work\n");
}
else
if(comment == 11)
{ printf("\nAlways prepared for class\n");
}
else
if(comment == 12)
{ printf("\nDoes well in drawing\n");
}
else
if(comment == 13)
{ printf("\nWith greater application work should improve\n");
}
else
if(comment == 14)
{ printf("\nMust pay attention to theory\n");
}
else
if(comment == 15)
{ printf("\nShows interest and is making progress\n");
}
else
if(comment == 16)
{ printf("\nDoes not express ideas effectively\n");
}
else
if(comment == 17)
{ printf("\nFinds the subject difficult\n");
}
else
if(comment == 18)
{ printf("\nShould try to be competent in all aspects of the foreign language\n");
}
else
if(comment == 19)
{ printf("\nHas difficulty with exams\n");
}
else
if(comment == 20)
{ printf("\nToo often absent from class\n");
}
else
if(comment == 21)
{ printf("\nPractical assignment not completed\n");
}
else
if(comment == 22)
{ printf("\nShows little interest\n");
}
else
if(comment == 23)
{ printf("\nPenmanship weak\n");
}
else
if(comment == 24)
{ printf("\nTest and/or assignment not done\n");
}
else
if(comment == 25)
{ printf("\nNeeds to read more widely\n");
}
else
if(comment == 26)
{ printf("\nNeeds to be punctual for class\n");
}
else
if(comment == 27)
{ printf("\nMinimum effort shown\n");
}
else
if(comment == 28)
{ printf("\nPoor attitude to work\n");
}
else
if(comment == 29)
{ printf("\nMuch too talkative\n");
}
else
if(comment == 30)
{ printf("\nNeeds to pay attention in class\n");
}
else
if(comment == 31)
{ printf("\nOften underprepared for class\n");
}
else
if(comment == 32)
{ printf("\nA noted drop in performance\n");
}
else
if(comment == 33)
{ printf("\nLack of text(s) hampers progress\n");
}
else
if(comment == 34)
{ printf("\nNeeds extra help\n");
}
else
{ Beep(523,500); //523 hertz (C5) for 500 milliseconds
printf("\nInvalid! Not a Comment");
}
printf("\n______________________________________________________________________\n\n");
//STUDENT CONDUCT
scanf("%c", &conduct);
printf("\nO\tOutstanding");
printf("\nG\tGood");
printf("\nS\tSatisfactory");
printf("\nF\tFair");
printf("\nU\tUnsatisfactory");
printf("\nP\tPoor");
printf("\nD\tDisruptive");
printf("\n\n Enter Conduct Letter\t\t\t");
scanf("%c", &conduct);
if(conduct == 'O' ||conduct == 'o')
{ printf("\nConduct in class is Outstanding\n");
}
else
if(conduct == 'G' ||conduct == 'g')
{ printf("\nConduct in class is Good\n");
}
else
if(conduct == 'S' ||conduct == 's')
{ printf("\nConduct in class is Satisfactory\n");
}
else
if(conduct == 'F' ||conduct == 'f')
{ printf("\nConduct in class is Fair\n");
}
else
if(conduct == 'U' ||conduct == 'u')
{ printf("\nConduct in class is Unsatisfactory\n");
}
else
if(conduct == 'P' ||conduct == 'p')
{ printf("\nConduct in class is Poor\n");
}
else
if(conduct == 'D' ||conduct == 'd')
{ printf("\nConduct in class is Disruptive\n");
}
else
{ Beep(523,500); //523 hertz (C5) for 500 milliseconds
printf("\nInvalid! Not a Conduct\n");
}
getch ();
getch (); clrscr ();
menu ();
break; //end case
case 2:
printf("\n\n");
printf("\t\tÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n");
printf("\t\t³\t FORM TEACHER ³\n");
printf("\t\tÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ\n\n");
//ACTIVITY
textcolor(3);
gotoxy(22,46);
cprintf(" Enter Student Name: ");
scanf("%s %s", &Christian, &Surname);
printf("\n_____________________________________________________________________\n");
printf("\nBadminton:\t\t1");
printf("\nBand:\t\t\t2");
printf("\nBasketball:\t\t3");
printf("\nBible Club:\t\t4");
printf("\nChoir:\t\t\t5");
printf("\nCricket:\t\t6");
printf("\nDebating:\t\t7");
printf("\nDrama:\t\t\t8");
printf("\nEnvironmental:\t\t9");
printf("\nEssay Competition:\t10");
printf("\nFootball:\t\t11");
printf("\nLawn Tennis:\t\t12");
printf("\nSchool Magazine:\t13");
printf("\nScience:\t\t14");
printf("\nSwimming:\t\t15");
printf("\nTable Tennis\t\t16");
printf("\nVolley Ball:\t\t17");
printf("\n_____________________________________________________________________\n");
printf("\n\n Enter Activity Number:\t");
scanf("%d", &activity);
if(activity == 1)
{ printf("\nPlays Badminton");
}
else
if(activity == 2)
{ printf("\nIs in the School Band");
}
else
if(activity == 3)
{ printf("\nPlays Basketball");
}
else
if(activity == 4)
{ printf("\nIs a member of the Bible Club");
}
else
if(activity == 5)
{ printf("\nIs a member of the Choir");
}
else
if(activity == 6)
{ printf("\Plays Cricket");
}
else
if(activity == 7)
{ printf("\nIs in the Debating Club");
}
else
if(activity == 8)
{ printf("\nIs a member of the Drama Club");
}
else
if(activity == 9)
{ printf("\nIs a member of the Environmental Club");
}
else
if(activity == 10)
{ printf("\nIs involved in the Essay Competition");
}
else
if(activity == 11)
{ printf("\nPlays Football");
}
else
if(activity == 12)
{ printf("\nPlays Lawn Tennis");
}
else
if(activity == 13)
{ printf("\nIs on the School Magazine Committe");
}
else
if(activity == 14)
{ printf("\nIs in the Science Club");
}
else
if(activity == 15)
{ printf("\nDoes Swimming");
}
else
if(activity == 16)
{ printf("\nPlays Table Tennis");
}
else
if(activity == 17)
{ printf("\nPlays Volley Ball");
}
else
printf("N/A");
//POSITION HELD BY STUDENT
printf("\n_____________________________________________________________________\n");
printf("\n\n Position (s) Held:\t");
scanf("%s", &position);
//REGISTER
printf("\n\n_____________________________________________________________________\n");
printf("\nNo. Days In Year:\t");
scanf("%d", &Dyear);
printf("\nNo. Sessions Late:\t");
scanf("%d", &Slate);
printf("\nNo. Days Absent:\t");
scanf("%d", &Dabsent);
printf("\n_____________________________________________________________________\n");
Dpresent = Dyear - Dabsent;
printf("\nStudent has been present for:\t%d of %d Days in School Year", Dpresent, Dyear);
printf("\n_____________________________________________________________________\n");
//RECOMMENDATION TO PARENT
printf("\nPARENT/GUARDIAN please come in to see or contact \n");
scanf("%s", &See);
getch (); clrscr ();
menu ();
break; //end case
case 3:
//FIND STUDENT GRADES
printf("\n\n");
printf("\t\tÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n");
printf("\t\t³\t STUDENT RECORDS ³\n");
printf("\t\tÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ\n\n");
textcolor(LIGHTRED);
cprintf("\r\n Enter Student Name: ");
scanf("%s%s", &Christian, &Surname);
getch (); clrscr ();
menu ();
break; //end case
case 4:
printf("\n\n");
printf("\t\tÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n");
printf("\t\t³\t INDEPENDENT CALCULATOR ³\n");
printf("\t\tÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ\n\n");
printf("\n Enter Amount of Numbers for Operation:\t");
scanf("%d",&n);
printf("\n_____________________________________________________________________\n");
printf("\nEnter Figures\n\n");
for( I=0;I < n;I++)
scanf("%d",&a[I]);
for( I=0;I < n;I++)
{
sum=sum+a[I];
}
avg = sum/n;
printf("\nThe Sum of the Numbers is:\t %d", sum);
printf("\n\nThe Average of Numbers is:\t %.1f", avg);
getch ();
getch (); clrscr ();
menu ();
break; //end case
case 5:
//STUDENT'S INFORMATION
printf("\n\n");
printf("\t\tÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n");
printf("\t\t³\t STUDENT INFORMATION ³\n");
printf("\t\tÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ\n\n");
textcolor(LIGHTRED);
cprintf("\r\n Enter Student's Form: ");
scanf("%s", &Form);
printf("\n_____________________________________________________________________\n\n");
static const char studentinfo[] = "StudentInformation.txt";
FILE *file = fopen(studentinfo, "r");
if (file != NULL)
{
char line [ 5000 ];
while(fgets (line, sizeof line, file) != NULL)
{
fputs(line, stdout);
}
fclose (file);
}
else
{
perror (studentinfo);
}
getch (); clrscr ();
menu ();
break; //end case
} //end switch
getch ();
} //end while
} //end menu
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
line 217-354: convert that to a switch statement. And next time user [code=c] ... [/code] code tags
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.