You are on page 1of 5

USER DOCUMENTATION

1. DESCRIPTION The program is intended to recommend Awards and Award C assi!ications !or a st"dent# gi$en in!ormation on a st"dent%s e&am res" ts !or each mod" e ta'en thro"gho"t the co"rse. Possi( e Awards which a candidate ma) achie$e inc "de* I+ Msc II+ Postgrad"ate Dip oma III+ Postgrad"ate Certi!icate Possi( e C assi!ications which a candidate ma) achie$e on a gi$en Award inc "de* I+ Distinction II+ Merit III+ Pass The program a"tomatica ) recommends the highest possi( e Award and C assi!ication !or the st"dent. In the e$ent which a st"dent !ai s to meet the criteria !or an) awards# the program grades the st"dent with a %,ai %. The recommendation is done () !irst reading in a te&t !i e containing each st"dent%s ID n"m(er and mod" e mar's# then prod"cing a new te&t !i e which ists each st"dent in order o! decreasing merit !or their awards# and () ID n"m(er !or tied awards. The program wi a so e&p ain the award and c assi!ication (eing recommended in the o"tp"t !i e.

-. INSTRUCTIONS The program can (e r"n "sing the e&ec"ta( e named ./100/1.e&e2. The method descri(ed here is !or 3in"& s)stems "sing a Termina to r"n the program4 in order to r"n the program on 5indows or other machines# it wo" d (e necessar) to recompi e the C code which can (e !o"nd in the 6ipped !o der ca ed ./100/1.6ip2. Three other !i es are re7"ired in order to r"n the program* I+ A te&t !i e containing a the mod" e data 8 This can (e !o"nd in the 6ipped !o der# and is named .mod" eData.t&t2. II+ An inp"t !i e containing each st"dent%s res" ts on a separate ine. III+ An o"tp"t !i e 8 This does not ha$e to (e created (e!orehand# the program wi create a new !i e i! there isn%t one. A o! these !i es m"st (e ocated in the program director) in order !or the program to wor'.

The inp"t !i e m"st adhere strict ) to the !o owing !ormat# otherwise the program wi report an error message and wi not r"n "nti the error is !i&ed* Each ine o! the inp"t !i e consists o! 1- comma9separated $aria( es :CS;%s+# with no spaces (etween an) o! the characters. Each ine corresponds to the res" ts o! a di!!erent st"dent. The !irst CS; corresponds to the st"dent%s ID n"m(er4 a !o owing CS;%s !irst correspond to the st"dent%s mod" e mar's in the order descri(ed in .mod" eData.t&t2# then resit mar's in the same order :e&c "ding the pro<ect mod" e# !or which there are no resits+ Once a o! these !i es ha$e (een prepared# the program can (e r"n "sing the !o owing steps* I+ Open the 3in"& termina and change director) to the pro<ect director). II+ R"n the !o owing command# rep acing .st"dentRes" t.dat2 and .o"tp"t,i e.dat2 with the names o! the inp"t and o"tp"t !i es respecti$e )* ./013304.exe studentResults.dat outputFile.dat III+ Open the o"tp"t !i e "sing a te&t editor s"ch as =edit or ;im to $iew the program o"tp"t.

TEC>NICA3 DOCUMENTATION
DATA STRUCTURES There are two main data str"ct"res "sed* 1. struct module This str"ct ho ds a the in!ormation a(o"t a gi$en mod" e# as !o"nd in moduleData.txt. It contains eight e ements# which are* :a+ inde& * an int to store the inde& n"m(er o! the mod" e in a ist o! a the mod" es :(+ gro"p * an int to store whether the mod" e is in =ro"p 1# -# or 0 :c+ code * a char arra) to store the mod" e code :d+ tit e * a char arra) to store the name o! the mod" e :e+ credits * an int to store the credit $a "e o! the mod" e :!+ sem * an int to store the semester in which the mod" e is ta'en :g+ mar' * an int to store the mar's o(tained in that mod" e () a st"dent :h+ resit * an int to store the mar's o(tained in resitting that mod" e () a st"dent -. struct student This str"ct ho ds a the in!ormation !or a gi$en st"dent. The e ements it contains are* :a+ :(+ :c+ :d+ :e+ :!+ :g+ :h+ :i+ :<+ :'+ * an int to store the st"dent%s ID n"m(er * an int to store the credits earned !or the pro<ect mod" e * an int to store the credits earned !rom =ro"p 1 mod" es * an int to store the credits earned !rom =ro"p - mod" es * an int to store the tota credits earned !rom a mod" es * an int to store the tota credit $a "e o! a mod" es which scored (e ow 1/? * an int to store the credits ta'en !or the pro<ect mod" e * an int to store the credits ta'en !or =ro"p 1 mod" es * an int to store the credits ta'en !or =ro"p - mod" es * an int to store the tota credits ta'en !rom a mod" es sortedMar'sInds * an int arra) which stores the inde& n"m(ers o! a ta'en mod" es in descending order o! mar's : + owa * an int to store the o$era weighted a$erage mar' o! the st"dent :m+owa@wr * an int to store the o$era weighted a$erage mar' o! the st"dent# ta'ing into acco"nt resits :n+ cwa@1-/ * an int to store the credit weighted a$erage mar' o! the st"dent%s (est 1-/ mod" es :o+ cwa@1-/@wr * an int to store the credit weighted a$erage mar' o! the st"dent%s (est 1-/ credits% worth o! mod" es :p+ cwa@A/ * an int to store the credit weighted a$erage mar' o! the st"dent%s (est A/ mod" es :7+ cwa@A/@wr * an int to store the credit weighted a$erage mar' o! the st"dent%s (est A/ credits% worth o! mod" es :r+ !cwa * an int to store the !ina credit weighted a$erage mar' :s+ !cwa@wr * an int to store the !ina credit weighted a$erage mar'# ta'ing into acco"nt resits :t+ award * an int to store the !ina award and c assi!ication o! the st"dent id creditsP credits1 creditstota Credits hard!ai s ta'enCP ta'enC1 ta'enCta'enTC

,UNCTIONS 1. void getModules(FILE *data, MODULE allModules[]) ; This !"nction ta'es two arg"ments. The !irst arg"ment is a te&t !i e containing data a(o"t a the mod" es# and the second is a str"ct arra) which wi store a the mod" e data read !rom the te&t !i e. The !"nction does not ret"rn an)thing4 it writes direct ) into the MODU3E str"ct since the second arg"ment is a pass9()9re!erence to the MODU3E arra). -. void getMarks(FILE *fin, STUDENT *student) ; This !"nction ta'es two arg"ments. The !irst arg"ment is the inp"t data !i e containing the st"dent%s mar's !or each mod" e# and the second is a pointer to a str"ct arra) which wi store the st"dent data read !rom the data !i e. The !"nction does not ret"rn an)thing4 it writes direct ) into the STUDENT str"ct"re since the second arg"ment is a pointer to the c"rrent STUDENT str"ct. 0. calculateCredits(STUDENT* student) ; This !"nction ta'es one arg"ment# which is a pointer to the str"ct STUDENT# which is "sed to store the prod"cts o! the ca c" ations in the !"nction. The !"nction does not ret"rn an)thing since the $a "es are written direct ) to the memor) ocation o! the STUDENT str"ct. This !"nction is responsi( e !or ca c" ating and assigning nine di!!erent $a "es to $aria( es in the STUDENT str"ct* hard!ai s# ta'enCP# creditsP# ta'enC1# credits1# ta'enC-# credits-# ta'enTC and tota Credits. Additiona )# the !"nction chec's i! the st"dent has ta'en at east B/ credits !rom =ro"p 1 mod" es# and at most 0/ credits !rom =ro"p - mod" es. I! either condition is !a se# the !"nction prints an error message. 1. void sortMarks(STUDENT *student) ; This !"nction ta'es one arg"ment# which is a pointer to the str"ct STUDENT# which is "sed to store the !ina sorted inde& arra). The !"nction does not ret"rn an)thing# ("t it writes to the arra) sortedMar'sInds in the str"ct STUDENT. The method "sed !or sorting the mod" es () mar's is simp ) () !inding the highest9mar'9 mod" e# writing that to the sorted arra)# then changing the mar' to / so that on the ne&t iteration# the second highest mod" e wi (e !o"nd and written to the sorted arra)# and so on. This method was pre!erred o$er other sorting a gorithms (eca"se the n"m(er o! e ements to sort is sma # hence time comp e&it) is not a (ig concern# and this method wins in ease o! coding and reada(i it). C. int creditWeightedAverage(STUDENT* student, int creditMax) ; This !"nction ta'es two arg"ments. The !irst arg"ment is a pointer to the str"ct STUDENT# which is "sed to store the credit weighted a$erage mar' o! the st"dent once the !"nction has ca c" ated it. The second arg"ment# creditMa&# indicates the tota credit $a "e o! the (est mod" es which sho" d (e considered in ca c" ating the credit weighted a$erage. Th"s i! the second arg"ment is 1-/# the !"nction wi ret"rn the $a "e o! the credit weighted

a$erage !or the (est 1-/ credit $a "es o! mod" es# A/ ret"rns the credit weighted a$erage mar' !or the (est A/ credits and C// :an ar(itrari ) arge n"m(er4 the st"dent wo" d ha$e ta'en mod" es worth o$er C// credits+ ret"rns the credit weighted a$erage mar' !or a ta'en mod" es. The !"nction ignores the st"dent%s pro<ect mod" e i! the creditMa& arg"ment is A/# since the pro<ect mod" e is not ta'en into acco"nt !or (est9A/9credits credit weighted a$erages. >owe$er# there are some 7"ir's in the ca c" ation !or credit weighted a$erages in this !"nction which sho" d (e ta'en note o!* ,irst )# i! the st"dent has ta'en ess mod" es than the creditMa&# then the !"nction wi ret"rn the credit weighted a$erage !or a the mod" es ta'en. This 7"ir' is ta'en ad$antage o! () "sing an ar(itrari ) arge creditMa& to ca c" ate the o$era weighted a$erage mar' !rom a the st"dent%s ta'en mod" es. Second )# the !"nction does not a wa)s ca c" ate the credit weighted a$erage o! e&act ) the (est :creditMa&+ credits o! mod" es. It might (e e&pected that# !or e&amp e# i! the creditMa& arg"ment gi$en is A/# the !"nction sho" d ret"rn the credit weighted a$erage o! the (est A/ credits. >owe$er# this t"rns o"t to (e a decepti$e ) tric') pro( em. ,or e&amp e# i! the st"dent%s (est 1 mod" es were worth -/# 1/# -/ and -/ credits respecti$e )# the tota credits o! the st"dent%s (est mod" es wo" d add "p to D/# which is more than the intended A/. So in act"a ) !act# the !"nction wo" d ret"rn the credit weighted a$erage !or the (est D/ credits o! mod" es# rather than the (est A/ credits. Ne$erthe ess# !or simp icit)%s sa'e# we a ow this detai to pass. A. int creditWeightedAverage_wResits(STUDENT* student, int creditMax) ; This !"nction is e&act ) the same as the pre$io"s !"nction n"m(er C# e&cept that# where the st"dent%s resit mar's are (etter !or a gi$en mod" e# the resit mar's are "sed in ca c" ating the credit weighted a$erage mar' instead o! the origina mar's. D. void handleBorderline(FILE *fout, STUDENT *student, int higherClass) ; This !"nction ta'es three arg"ments. The !irst arg"ment is the ,I3E pointer to the program%s o"tp"t !i e. The second arg"ment is a pointer to the str"ct STUDENT. The third arg"ment "ses integers to indicate the c assi!ication o! the (order ine case 8 0 !or Merit9Distinction# - !or Pass9Merit# and 1 !or ,ai 9Pass. The !"nction does not ret"rn an)thing4 it prints the reasoning and recommendation o! the (order ine case to the o"tp"t !i e# and ad<"sts the award c assi!ication recorded in the STUDENT str"ct according ). E. void describeAward(FILE *fout, int award) ; This !"nction ta'es two arg"ments. The !irst arg"ment is the ,I3E pointer to the program%s o"tp"t !i e. The second arg"ment "ses integers to indicate# in ascending order o! merit# the e$e o! award achie$ed () the st"dent. ,or e&amp e# / indicates a ,ai # 1 indicates a Postgrad"ate Dip oma Pass# - indicates a Postgrad"ate Dip oma with Merit# and so on "nti B which indicates an Msc with Distinction. The !"nction does not ret"rn an)thing4 it on ) prints the name o! the award to the o"tp"t !i e.

You might also like