// marking system (Dec 2, 2011) cs2xx 陳大文 5D99 #include #include "console.c" #define MAX 5 int score[?][?], studTL[?], subjTL[?], gradeTL[?]; void cal_totals(){ int i,j,n; float avg; /* for (i=0;i85) n=0; else ... gradeTL... } */ } void displayScore(){ int i,j; printf("ST\tChi\tEng\tMath\tTotal\tAvg\n"); for (i=0;i> \n"); printf("\t(r) random scores \n"); printf("\t(k) from keyboard \n"); printf("\t(f) from file \n"); // scores.txt printf("\t(q) quit/exit \n"); printf("\tQ: option "); fflush(stdin); /* opt = ... printf("\n\n"); if(opt=='Q') ... switch(opt) { case random_scores(); case input_score(); case scoreFromFile(); } */ cal_totals(); // 計算總和 displayScore(); // 顯示結果 } main() { char opt='Q'; do { // clrscr(); printf("<< Marking System >> \n"); printf("(1) input scores \n"); printf("\t(r) random scores \n"); printf("\t(k) from keyboard \n"); printf("\t(f) from file \n"); // scores.txt printf("(2) score list \n"); printf("(3) frequency table \n"); printf("(4) statistics \n"); printf("(Q) quit \n"); printf("Q: option "); fflush(stdin); opt = toupper(getche()); printf("\n\n"); if(opt=='Q') break; switch(opt) { case '1': inputMenu(); break; case '2': displayScore(); break; case '3': freqTables(); break; case '4': statistics(); break; } } while(1); } /* Marking System: 分數處理系統 1. Store the names of at least 5 students in the appropriate array. 2. Accept scores (0-100) for each student on 3 subjects listed below. If any score entered by user is out of range, issue appropriate error message and let the user input again. 3. Calculate and store the average score and grade for each student. 4. Calculate and store the average score for each subject. 5. Construct and display the frequency table for each grade. 6. A menu-driven system with modular design is highly recommended. ------------------------------------------------------------------------------- | Main menu : Sub-menu: | | ------- Marking System ------ | | | <1> Input Scores | a) random scores | | | Calculate | b) from keyboard | | | <2> Score List | c) from scores.txt | | | <3> Frequency table | | | | <4> Statistics | | | | Quit | | | ----------------------------- | | Which choice <1-3,Q> ? 1 | | | | Input screen : Input scores (0-100) | | -------------------------------------------------------- | | | Name | Chinese | English | Maths | | | |---------------------|----------|----------|----------| | | | 1 Tai-man Chan | 75 | 76 | 77 | | | | 2 Ivan Hung | 70 | 65 | 50 | | | | : : | : | | | | | | 5 Eva Cheung | 85 | 67 | 100 | | | -------------------------------------------------------- | | | | Output screen 1 : Score List | | ----------------------------------------------------------------------- | | | Name | Chinese | English | Maths | Average/Grade | | | |---------------------|-----------|---------|---------|---------------| | | | 1 Tai-man Chan | 75 | 80 | 70 | 75.7 (B) | | | | 2 Ivan Hung | 70 | 65 | 50 | 62.1 (C) | | | | : : | : | | | | | | | 5 Eva Cheung | 85 | 67 | 100 | 81.6 (B) | | | |---------------------|-----------|---------|---------|---------------| | | | Average score | 75.0 | 58.5 | 60.3 | 64.6 (C) | | | ----------------------------------------------------------------------- | | | | Output screen 2 : Frequency table of overall result | | ---------------------------------------------------- | | | Grade | Range | Frequency | | | |-----------|--------------|-----------------------| | | | A | 86 - 100 | 0 | | | | B | 70 - 85 | 1 | | | | C | 50 - 69 | 3 | | | | D | 30 - 49 | 1 | | | | E | 00 - 29 | 0 | | | |--------------------------|-----------------------| | | | Total | 5 | | | ---------------------------------------------------- | ------------------------------------------------------------------------------- ---------------------------------------------------------------------------------- | List of variables used : | | ----------------------------------------------------------------------------- | | | Name | Chinese | English | Maths | Average / Grade | | | |---------|-------------|-------------|-------------|-----------------------| | | | name[0] | score[0][0] | score[0][1] | score[0][2] | studAvg[0] grade[0] | | | | name[1] | score[1][0] | score[1][1] | score[1][2] | studAvg[1] grade[1] | | | | : | | | | | | | | name[4] | score[4][0] | score[4][1] | score[4][2] | studAvg[4] grade[4] | | | |---------|-------------|-------------|-------------|-----------------------| | | | Average | SubjAvg[0] | SubjAvg[1] | SubjAvg[2] | SubjAvg[3] | | | ----------------------------------------------------------------------------- | | | | ---------------------------------------------------- | | | Grade | Range | Frequency | | | |-----------|--------------|-----------------------| | | | A | 86 - 100 | gradeTL[0] | | | | B | 70 - 85 | gradeTL[1] | | | | C | 50 - 69 | gradeTL[2] | | | | D | 30 - 49 | gradeTL[3] | | | | E | 00 - 29 | gradeTL[4] | | | |-----------|--------------|-----------------------| | | | | Total | total | | | ---------------------------------------------------- | --------------------------------------------------------- ------------------------------------------------------------------------------- | Output screen 3 : Histogram (optional) | | ----------------------------------------------------------------------- | | | Grade Frequency | | | | A *** | | | | B ******* | | | | C *************** | | | | D ***** | | | | E * | | | ----------------------------------------------------------------------- | | | | Output screen 4 : Histogram (optional) | | ----------------------------------------------------------------------- | | | Frequency | | | | | | | | 15 - * | | | | | * | | | | | * | | | | | * | | | | | * | | | | 10 - * | | | | | * | | | | | * | | | | | * * | | | | | * * | | | | 5 - * * * | | | | | * * * | | | | | * * * * | | | | | * * * * | | | | | * * * * * | | | | --|---------------------------------- | | | | | A B C D E (Grade) | | | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------- scores.txt Tai-man Chan 95 88 90 Ivan Hung 87 91 76 Alex Tsui 77 98 91 James Wong 56 58 63 Eva Cheung 88 77 55 123456789-123456789-123456789-123456789- */