1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.IO;4 usingSystem.Linq;5 usingSystem.Text;6 usingSystem.Threading.Tasks;7 8 namespaceSum9 {Ten class Program One { A Static voidMain (string[] args) - { - //Get Total the string[] Totaldata = File.ReadAllLines (@"D:\sum\temp.txt"); - - #regionDeclaring an array - intNumber = the; + - Double[] Credit =New Double[] {4,4.5,4,2,5,4.5,7.5,4.5,2,2,2,2,4.5,4,2 }; + A Double[] score =New Double[number]; at - Double[] Scoretotal =New Double[number]; - - DoubleTotalcredit =0.0; - - DoubleAllstudentscore =0.0; in - DoubleFinalresult =0.0; to +StringBuilder Strfinalresult =NewStringBuilder (); - #endregion the * #regionGet Data $ Panax Notoginseng for(intj =0; J < Totaldata.length; J + +) - { the #regionExtract score Information + for(inti =0; I < number; i++) A { theScore[i] = convert.todouble (Totaldata[j]. Replace ('\ t','&'). Split (New Char[] {'&'}) [i]. ToString (). Trim ()); + } - #endregion $ $ #regionPartial data calculation - //credit multiplied by the score - for(inti =0; I < number; i++) the { - //The sum of each studentWuyiScoretotal[i] = credit[i] *Score[i]; the } - Wu //all student credits multiplied by results - for(inti =0; I < number; i++) About { $Allstudentscore + =Scoretotal[i]; - } - - //Total Credits A for(inti =0; I < number; i++) + { theTotalcredit + =Credit[i]; - } $ #endregion the the #regionFinal calculation results theFinalresult = Allstudentscore/Totalcredit; the #endregion - in #regionOutput results the stringstrpath =@"D:\sum\result.txt"; theStreamWriter fs =NewStreamWriter (strpath,false, System.Text.Encoding.Default); About //string num = convert.tostring (j+1) + ":"; theStrfinalresult.append (finalresult.tostring () +System.Environment.NewLine); the FS. WriteLine (Strfinalresult); the FS. Close (); + #endregion - } the #endregionBayi theConsole.WriteLine (@"Check the contents of the [D:\sum\result.txt] file at the end of the calculation! "); the - Console.readkey (); - } the } the}
Statistical credit Score