Exemplo n.º 1
0
 public void UpdateLists()
 {
     marks       = Marks.Split(',').Select(int.Parse).ToList();
     comments    = Comments.Split(';').ToList();
     images      = Images.Split(',').ToList();
     MedianGrade = double.Parse(marks.ElementAt(0).ToString());
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            string str           = string.Empty;
            int    StudentNumber = 0;
            string Marks;

            string[] StudentMark;

            do
            {
                Console.Write("학생 수를 입력하세요: ");
                StudentNumber = int.Parse(Console.ReadLine());

                if (StudentNumber <= 0)
                {
                    Console.WriteLine("학생 수를 잘못 입력하였습니다.\n다시 입력하여 주세요.");
                }
                else
                {
                    break;
                }
            } while (true);

            //StudentMark = new string[StudentNumber];

            for (int i = 0; i < StudentNumber; i++)
            {
                Console.WriteLine("{0}번 학생의 점수를 입력해 주세요.", i + 1);
                Marks       = Console.ReadLine();
                StudentMark = Marks.Split(new char[] { ' ' });
                using (StreamWriter sw = new StreamWriter(new FileStream("StudentMarks.txt", FileMode.Append, FileAccess.Write)))
                {
                    sw.WriteLine("국어: {0}, 영어: {1}, 수학: {2}", StudentMark[0], StudentMark[1], StudentMark[2]);
                }
            }
        }
Exemplo n.º 3
0
        public void display()
        {
            StreamReader srMarks;
            StreamReader srLecturerMarks;
            StreamReader srTestCount;
            string       display = "";

            try
            {
                //get number of questions
                String filepathTestCount = "Test.txt";
                srTestCount = new StreamReader(filepathTestCount);
                string t;
                t = srTestCount.ReadToEnd();
                String[] tCount = t.Split('\n');
                int      qNum   = tCount.Length;//how many answered questions
                srTestCount.Close();
                //

                String filepathMarks = "TestMarks.txt";
                srMarks = new StreamReader(filepathMarks);
                string Marks;
                Marks = srMarks.ReadToEnd();
                String[] AllMarks = Marks.Split('\n');
                int      l = AllMarks.Length - 1;//\n in text file
                int      i = 0, x = 0, total = 0, n = 1, high = 0, low = 10000;
                string   highStd = "", lowStd = "";


                while (l >= i)
                {
                    if (n <= l)
                    {
                        Int32.TryParse(AllMarks[(n)], out x);
                        total = total + x;

                        if (x > high)
                        {
                            high    = x;
                            highStd = AllMarks[n - 1];
                        }
                        if (low > x)
                        {
                            low    = x;
                            lowStd = AllMarks[n - 1];
                        }
                    }
                    display = display + "\n" + AllMarks[i];
                    n       = n + 2;
                    i++;
                }
                //save to file
                display = display + "\n Average: " + (total / ((l - 1) / 2)) + "\n Highest Mark: " + high + " by " + highStd + "\n Lowest Mark: " + low + " by " + lowStd + "\n The test was out of " + qNum + " marks";//avg note -1 for \n
                File.WriteAllText("LecturerMarks.txt", display + Environment.NewLine);

                //read from file

                String filepathLecturerMarks = "LecturerMarks.txt";
                srLecturerMarks = new StreamReader(filepathLecturerMarks);
                string LMarks;
                LMarks = srLecturerMarks.ReadToEnd();
                String[] LecturerMarks = LMarks.Split('\n');
                int      lm            = LecturerMarks.Length - 1;///
                int      y             = 0;
                while (y <= lm)
                {
                    lbxDisplay.Items.Add(LecturerMarks[y]);
                    y++;
                }
            }
            catch (System.IO.FileNotFoundException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }