using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace STaha_ASS01_SatecVSR.H.King { class Program { static void Main(string[] args) { satec(); RH_king(); } static public double work(string[] free_energy) { double heat = 0; for (int i = 1; i < free_energy.Length - 1; i++) { heat += Int32.Parse(free_energy[i]); } heat = Math.Round((heat / (free_energy.Length - 2)), 2); return heat; } static public void RH_king() { int counter = 0; string line; double RH_CSC = 0; double RH_ENG = 0; double RH_HIS = 0; double RH_MTH = 0; double RH_PHY = 0; if (File.Exists("RHKing.txt")) { System.IO.StreamReader bile = new System.IO.StreamReader("RHKing.txt"); while ((line = bile.ReadLine()) != null) { counter++; string[] satec_size = line.Split(null); if (counter == 1) { RH_CSC = work(satec_size); } if (counter == 2) { RH_ENG = work(satec_size); } if (counter == 3) { RH_HIS = work(satec_size); } if (counter == 4) { RH_MTH = work(satec_size); } if (counter == 5) { RH_PHY = work(satec_size); } } Console.WriteLine(RH_CSC); Console.WriteLine(RH_ENG); Console.WriteLine(RH_HIS); Console.WriteLine(RH_MTH); Console.WriteLine(RH_PHY); bile.Close(); } else Console.WriteLine("The file with the information pertaining to RHking Is nonexistant."); Console.ReadLine(); } static public void satec() { int counter = 0; string line; double S_CSC = 0; double S_ENG = 0; double S_HIS = 0; double S_MTH = 0; double S_PHY = 0; if (File.Exists("Satec.txt")) { System.IO.StreamReader file = new System.IO.StreamReader("Satec.txt"); while ((line = file.ReadLine()) != null) { counter++; string[] satec_size = line.Split(null); if (counter == 1) { S_CSC = work(satec_size); } if (counter == 2) { S_ENG = work(satec_size); } if (counter == 3) { S_HIS = work(satec_size); } if (counter == 4) { S_MTH = work(satec_size); } if (counter == 5) { S_PHY = work(satec_size); } } Console.WriteLine(S_CSC); Console.WriteLine(S_ENG); Console.WriteLine(S_HIS); Console.WriteLine(S_MTH); Console.WriteLine(S_PHY); file.Close(); } else Console.WriteLine("The file with the information pertaining to satec is non existant."); Console.ReadKey(); } } }