Exemplo n.º 1
0
        public void showAvgBynum(students s, List <selectCourses> sc)
        {
            this.clearScrean();

            if (s == null)
            {
                Console.WriteLine("Not found strudent\n");
                goto exit;
            }

            Console.WriteLine("fname\tlname\t\tavg");
            Console.WriteLine("---------------------------------------");

            int   vahed_all = 0;
            int   sum_all   = 0;
            float avg       = 0;

            foreach (var item in sc)
            {
                if (s.num == item.st.num)
                {
                    vahed_all += item.cr.vahed;
                    sum_all   += (item.avg * item.cr.vahed);
                }
            }

            try
            {
                avg = (sum_all / vahed_all);
            }
            catch
            {
                // zero division
                avg = 0;
            }


            Console.WriteLine("{0}\t{1}\t{2}", s.firstname, s.lastname, avg);

exit:
            Console.Write("press Enter to continue...");
            Console.ReadLine();
        }
Exemplo n.º 2
0
 public selectCourses(students s, courses c, int av)
 {
     this.st  = s;
     this.cr  = c;
     this.avg = av;
 }