Example #1
0
        static void Main(string[] args)
        {
            School[] school = new School[5];
            for (int i = 0; i < school.Length; i++)
            {
                Console.Write("Input enrollment size of school {0}: ", i);
                string input = Console.ReadLine();
                int enrollment = Convert.ToInt32(input);
                school[i] = new School();
                school[i].Enrolled = enrollment;
            }

            Array.Sort(school);
            Console.WriteLine("Sorted Schools:");
            for (int i = 0; i < school.Length; i++)
            {
                Console.WriteLine("{0}", school[i].Enrolled);
            }

            Console.Write("Minimum enrollment size: ");
            string MinEnroll = Console.ReadLine();
            int minEnroll = Convert.ToInt32(MinEnroll);

            for (int i = 0; i < school.Length; i++)
            {

                if (school[i].Enrolled >= minEnroll)
                    Console.WriteLine(school[i].Enrolled);
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            string schoolname;
            int enrollment, minenrollment;
            int i;

               School[] school = new School[5];

            for(i = 0; i < school.Length; i++)
            {
                GetData(out schoolname, out enrollment);

                school[i] = new School(schoolname, enrollment);
            }

            Array.Sort(school);
            Console.WriteLine("Sorted List:");

            for (i = 0; i < school.Length; i++)
            {
                Console.WriteLine(school[i].schoolname);
            }

            Console.Write("Enter minimum enrollment: ");
            string input = Console.ReadLine();
            minenrollment = Convert.ToInt32(input);

             for (i = 0; i < school.Length; i++)
             {
                if (school[i].enrollment >= minenrollment)
                    Console.WriteLine(school[i].schoolname + school[i].enrollment);
             }
        }
Example #3
0
        public static void Main()
        {
            School[] schoolArray = new School[5];
            int x;
            string[] studentsInput = { "a", "a", "a", "a", "a" };

            for (x = 0; x < schoolArray.Length; ++x)
            {
                schoolArray[x] = new School();

                Console.WriteLine();
                Console.Write("  Please enter a school name :  ");
                schoolArray[x].name = Console.ReadLine();
                Console.Write("  Please enter a number of students that enroll to this school :  ");
                studentsInput[x] = Console.ReadLine();
                schoolArray[x].students = Convert.ToInt32(studentsInput[x]);
            }

            Console.WriteLine();

            Array.Sort(schoolArray);

            for (x = 0; x < schoolArray.Length; ++x)
            {
                Console.WriteLine();
                Console.WriteLine("  {0} currently has {1} students enrolled", schoolArray[x].name, schoolArray[x].students);
            }

            Console.ReadLine();
        }