| | |
student grading system
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2009
Posts: 6
Reputation:
Solved Threads: 0
Project Title : Student Grading System
Purpose : Calculate the grade and sort the student matrix in descending
example Input file : studentsmark.txt
example Output file: studentresult.txt
How the user operate the software:
1) user run the software
2) an interface show on the screen
3) user keyin Input file name (example:studentsmarks.txt)
4) user keyin Output file name (example:studentresult.txt)
5) user select function to calculate and sort
6) Then an output file stored student result generated
7) user can select option to continue another input file or quit the software
Formular:
1) please exam studentsmark.txt and studentresult.txt
2) the result listing in the studentresult.txt must be sort by student matrix
3) Grade : MARKS >= 80 Then A
MARKS >= 75 Then A-
MARKS >= 70 Then B+
MARKS >= 65 Then B
MARKS >= 60 Then B-
MARKS >= 55 Then C+
MARKS >= 50 Then C
MARKS >= 45 Then C-
MARKS >= 40 Then D+
MARKS >= 35 Then D
MARKS < 35 Then E
input file : studentsmark.txt
01234012345678901234567890123456789
0123401234567890123456789012345678901234567890123456789012345678901234567890123456789
No Matrix quiz1(5%) quiz1(5%) quiz1(5%) Proj(25%) MidT(20%)
1 BK20008 4 3 5 18 18
2 BK20002 5 5 4 10 8
3 BK20003 3 4 5 18 10
4 BK20006 4 3 4 20 14
5 BK20005 5 4 3 13 17
6 BK20004 2 5 2 4 16
7 BK20007 3 4 4 21 14
8 BK20001 4 3 5 11 15
9 BK20009 3 2 4 10 10
10 BK20010 4 3 3 23 18
i have written the first part that is to read the file content
but obviously it cannot run
it only can run if i remove the 1st line and matrix coloum, please tell me what to do..i'm real weak in programming..
Purpose : Calculate the grade and sort the student matrix in descending
example Input file : studentsmark.txt
example Output file: studentresult.txt
How the user operate the software:
1) user run the software
2) an interface show on the screen
3) user keyin Input file name (example:studentsmarks.txt)
4) user keyin Output file name (example:studentresult.txt)
5) user select function to calculate and sort
6) Then an output file stored student result generated
7) user can select option to continue another input file or quit the software
Formular:
1) please exam studentsmark.txt and studentresult.txt
2) the result listing in the studentresult.txt must be sort by student matrix
3) Grade : MARKS >= 80 Then A
MARKS >= 75 Then A-
MARKS >= 70 Then B+
MARKS >= 65 Then B
MARKS >= 60 Then B-
MARKS >= 55 Then C+
MARKS >= 50 Then C
MARKS >= 45 Then C-
MARKS >= 40 Then D+
MARKS >= 35 Then D
MARKS < 35 Then E
input file : studentsmark.txt
01234012345678901234567890123456789
0123401234567890123456789012345678901234567890123456789012345678901234567890123456789
No Matrix quiz1(5%) quiz1(5%) quiz1(5%) Proj(25%) MidT(20%)
1 BK20008 4 3 5 18 18
2 BK20002 5 5 4 10 8
3 BK20003 3 4 5 18 10
4 BK20006 4 3 4 20 14
5 BK20005 5 4 3 13 17
6 BK20004 2 5 2 4 16
7 BK20007 3 4 4 21 14
8 BK20001 4 3 5 11 15
9 BK20009 3 2 4 10 10
10 BK20010 4 3 3 23 18
i have written the first part that is to read the file content
but obviously it cannot run
C Syntax (Toggle Plain Text)
#include <stdio.h> void main (void) { char matrix[200]; int i, j, num_elem, no[20], quiz_1[20], quiz_2[20], quiz_3[20], project[20], midT[20]; FILE *infile; infile = fopen("studentsmark.txt","r"); i=1; while( fscanf(infile,"%d %s %d %d %d %d %d %d",&no[i],&matrix[i], &quiz_1[i], &quiz_2[i], &quiz_3[i], &project[i], &midT[i]) !=EOF) i++; num_elem = i; for(j=1;j<num_elem;j++) { printf("%d %s %d %d %d %d %d %d\n",no[j], matrix[i], quiz_1[j], quiz_2[j], quiz_3[j], project[j], midT[j]); } fclose(infile); }
it only can run if i remove the 1st line and matrix coloum, please tell me what to do..i'm real weak in programming..
Last edited by gseed87; Mar 21st, 2009 at 5:38 pm.
•
•
Join Date: Feb 2009
Posts: 71
Reputation:
Solved Threads: 9
Is all this stuff: part of the input file? If so, you have to add some code to read (and ignore) it before trying to read in the real data.
num_elem serves no real purpose, since you already have the value you need in i.
For the student ids, you want an array of strings, not one big string, so change
Array numbering starts at 0, not 1, so the initial value of i should be 0. Similarly, in the for loop the initial value of j should be 0.
Your fscanf statement and your printf statement both have an extra %d.
In the fscanf parameter list, use
C Syntax (Toggle Plain Text)
01234012345678901234567890123456789 0123401234567890123456789012345678901234567890123456789012345678901234567890123456789 No Matrix quiz1(5%) quiz1(5%) quiz1(5%) Proj(25%) MidT(20%)
num_elem serves no real purpose, since you already have the value you need in i.
For the student ids, you want an array of strings, not one big string, so change
char matrix[200] to char matrix[10][20] . (Perhaps the first dimension should be something bigger than 10 in case there will be more than 10 students.)Array numbering starts at 0, not 1, so the initial value of i should be 0. Similarly, in the for loop the initial value of j should be 0.
Your fscanf statement and your printf statement both have an extra %d.
In the fscanf parameter list, use
matrix[i] (no "&") since matrix[i] is already an address -- it's the address of the ith string -- after you change matrix to a 2-dimensional array as I suggested above. •
•
Join Date: Mar 2009
Posts: 6
Reputation:
Solved Threads: 0
this is my corrected code
but i still i am unable to read tis line
No Matrix quiz1(5%) quiz1(5%) quiz1(5%) Proj(25%) MidT(20%)
what should i add to make the program read it and ignore it so i can read on the real data i need, i really have no idea...
C Syntax (Toggle Plain Text)
#include <stdio.h> int main () { char matrix[20][200]; int i, j, no[20], quiz_1[20], quiz_2[20], quiz_3[20], project[20], midT[20]; FILE *infile; infile = fopen("studentsmark.txt","r"); i=0; while( fscanf(infile,"%d %s %d %d %d %d %d",&no[i], matrix[i], &quiz_1[i], &quiz_2[i], &quiz_3[i], &project[i], &midT[i]) !=EOF) i++; for(j=0;j<i;j++) { printf("%d %s %d %d %d %d %d\n",no[j], matrix[j], quiz_1[j], quiz_2[j], quiz_3[j], project[j], midT[j]); } fclose(infile); }
but i still i am unable to read tis line
No Matrix quiz1(5%) quiz1(5%) quiz1(5%) Proj(25%) MidT(20%)
what should i add to make the program read it and ignore it so i can read on the real data i need, i really have no idea...
•
•
Join Date: Feb 2009
Posts: 71
Reputation:
Solved Threads: 9
There are many ways to do this. Probably
By the way, it seems to me that you also have to get rid of the line
I don't understand what purpose that line serves, but you certainly don't want to read it into any of your existing variables. You can use the same function, e.g.
getc or fgetc would be the simplest for you. Look at a reference for stdio.h functions, for example this one, to see how to use those functions: http://www.cplusplus.com/reference/clibrary/cstdio/By the way, it seems to me that you also have to get rid of the line
C Syntax (Toggle Plain Text)
012340123456789012345678901234567890123456789012345678
getc , to take care of both header lines. •
•
Join Date: Mar 2009
Posts: 6
Reputation:
Solved Threads: 0
thanks again, i will try
this line is for column reference, that is what told by my lecturer..
C Syntax (Toggle Plain Text)
012340123456789012345678901234567890123456789012345678
this line is for column reference, that is what told by my lecturer..
•
•
Join Date: Feb 2009
Posts: 71
Reputation:
Solved Threads: 9
•
•
•
•
code]012340123456789012345678901234567890123456789012345678[/code]
this line is for column reference, that is what told by my lecturer..
So, if your assignment requires that to be in the file, I assume your instructor's intention was simply for you to learn how to write a program that can handle an input file in which different lines are formatted differently. And unless you have some other information that you haven't posted, the program doesn't have to use the data in those first two lines, but still must read them in order to get to the "real" data that follows.
Well, it donst make any sense of the input file that your trying to read with regards to the student grade information. If I was you, i would go your lecture and speak about on how the input file should be read. And how the file had been formatted with reference to the student grade information.
If you know that, then it makes it ease to read the chucks of the file where each chuck would be the information about one student!
-ssharish
If you know that, then it makes it ease to read the chucks of the file where each chuck would be the information about one student!
-ssharish
"Any fool can know, point is to understand"
•
•
Join Date: Mar 2009
Posts: 6
Reputation:
Solved Threads: 0
now my program able to read the input file, i add some code written by other forumer, but i could'nt understand how it actually run..looks like it skips the first 2 line and read the rest...
this is the code i add
C Syntax (Toggle Plain Text)
#include <stdio.h> void main (void) { char matrix[20][200], line[100][100]; int i, j, x, no[20], quiz_1[20], quiz_2[20], quiz_3[20], project[20], midT[20], final[20]; FILE *infile; infile = fopen("studentsmark.txt","r"); x=0; while (fgets(line,100,infile)!=NULL) { x++; if(x==1) { } else{ i=0; while( fscanf(infile,"%d %s %d %d %d %d %d %d",&no[i],matrix[i], &quiz_1[i], &quiz_2[i], &quiz_3[i], &project[i], &midT[i], &final[i]) !=EOF) printf("%d %s %d %d %d %d %d %d\n",no[i], matrix[i], quiz_1[i], quiz_2[i], quiz_3[i], project[i], midT[i], final[i]); i++; } } fclose(infile); }
this is the code i add
C Syntax (Toggle Plain Text)
int x = 0; while (fgets(line,100,infile)!=NULL) { x++; if(x==1) { } else{ } }
•
•
Join Date: Mar 2009
Posts: 6
Reputation:
Solved Threads: 0
this is the actual file i need to read..
C Syntax (Toggle Plain Text)
0123401234567890123456789012345678901234567890123456789012345678901234567890123456789 No Matrix quiz1(5%) quiz1(5%) quiz1(5%) Proj(25%) MidT(20%) Final(40%) 1 BK20008 4 3 5 18 18 36 2 BK20002 5 5 4 10 8 30 3 BK20003 3 4 5 18 10 35 4 BK20006 4 3 4 20 14 36 5 BK20005 5 4 3 13 17 28 6 BK20004 2 5 2 4 16 10 7 BK20007 3 4 4 21 14 32 8 BK20001 4 3 5 11 15 31 9 BK20009 3 2 4 10 10 20 10 BK20010 4 3 3 23 18 22
![]() |
Similar Threads
- How do I make vectors of an already vectorized thing? (C++)
- e-learning (PHP)
- Help/tips needed to create a software that grade students marks (C++)
- please help me debugg this program (grading System) (C++)
- Intro to Java help (Java)
- Help with an Array GRading assignment (Java)
- C++ program that will Manipulate exam results! (C++)
- Old School Compiler vs New Compiler (C++)
Other Threads in the C Forum
- Previous Thread: Alien numbers problem
- Next Thread: execute some code just before stopping program using CTRL-C
| Thread Tools | Search this Thread |
#include * ansi append array arrays asterisks bash binarysearch centimeter changingto char character convert copyimagefile cprogramme creafecopyofanytypeoffileinc createprocess() database dynamic execv fgets file floatingpointvalidation fork framework function getlogicaldrivestrin givemetehcodez grade gtkwinlinux hacking histogram ide inches include infiniteloop initialization input interest intmain() iso kernel keyboard kilometer km license linked linkedlist linux list lists looping lowest matrix meter microsoft number oddnumber open opendocumentformat openwebfoundation overwrite owf pdf pointer pointers posix power probleminc process program programming radix recursion recv recvblocked research reversing segmentationfault sequential single socket socketprogramming standard strchr string suggestions systemcall test testing threads turboc unix urboc user variable wab whythiscodecausesegmentationfault windowsapi





