We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Saturday, June 27, 2015

   A Class contains 3 batches. Create a batch with a different number of students. And a number of subjects also can be different. Print the batches.
      class BatchClass
    {
        static void Main(string[] args)
        {

            BatchClass p = new BatchClass();
            Console.WriteLine("\n----------------");
            Console.WriteLine("Batches:");

            Console.WriteLine("----------------\n");
            Console.Write(@"

1 -  Batch1

2 -  Batch2

3 -  Batch3
           Please select one (1, 2, or 3): ");
            string batchString = Console.ReadLine();
            switch (batchString)
                 {

                case "1":

                    p.Batch1();

                    break;

                case "2":

                    p.Batch2();

                    break;

                case "3":

                    p.Batch3();

                    break;

            }

        }

        public void Batch1()
        {

            Console.WriteLine("Welcome to Batch1");

            Console.WriteLine("Enter number of students in Batch1");

            int num = int.Parse(Console.ReadLine());

            string[] arr1 = new string[num];

            Console.WriteLine("Enter the students name of the batch1");

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

            {

                arr1[i] = Console.ReadLine();

            }

            Console.WriteLine("Enter number of  subjects of batch1");

            int numsub = int.Parse(Console.ReadLine());

            string[] sub1 = new string[numsub];

            Console.WriteLine("Enter name of  subjects of batch1");

            for (int i = 0; i < numsub; i++)

            {

                sub1[i] = Console.ReadLine();

            }

            Console.WriteLine();

            Console.WriteLine("Batch1");

            Console.WriteLine("The students of Batch1 are: ");

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

            {

                Console.WriteLine(arr1[i]);

            }

            Console.WriteLine();

            Console.WriteLine("The subjects of Batch1 are: ");

            for (int i = 0; i < numsub; i++)

            {

                Console.WriteLine(sub1[i]);

            }

            Console.ReadLine();

        }

        public void Batch2()

        {

            Console.WriteLine("Welcome to Batch2");

            Console.WriteLine("Enter number of students in Batch2");

            int num = int.Parse(Console.ReadLine());

            string[] arr2 = new string[num];

            Console.WriteLine("Enter the students name of the batch2");

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

            {

                arr2[i] = Console.ReadLine();

            }

            Console.WriteLine("Enter number of  subjects of batch2");

            int numsub = int.Parse(Console.ReadLine());

            string[] sub2 = new string[numsub];

            Console.WriteLine("Enter name of  subjects of batch2");

            for (int i = 0; i < numsub; i++)

            {

                sub2[i] = Console.ReadLine();

            }

            Console.WriteLine();

            Console.WriteLine("BATCH2");

            Console.WriteLine("The students of Batch2 are: ");

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

            {

                Console.WriteLine(arr2[i]);

            }

            Console.WriteLine();

            Console.WriteLine("The subjects of Batch2 are: ");

            for (int i = 0; i < numsub; i++)

            {

                Console.WriteLine(sub2[i]);

            }

            Console.ReadLine();

        }

        public void Batch3()

        {

            Console.WriteLine("Welcome to BATCH3");

            Console.WriteLine("Enter number of students in Batch3");

            int num = int.Parse(Console.ReadLine());

            string[] arr3 = new string[num];

            Console.WriteLine("Enter the students name of the batch3");

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

            {

                arr3[i] = Console.ReadLine();

            }

            Console.WriteLine("Enter number of  subjects of batch3");

            int numsub = int.Parse(Console.ReadLine());

            string[] sub3 = new string[numsub];

            Console.WriteLine("Enter name of  subjects of batch3");

            for (int i = 0; i < numsub; i++)

            {

                sub3[i] = Console.ReadLine();

            }

            Console.WriteLine();

            Console.WriteLine("You Select Batch3");

            Console.WriteLine("The students of Batch3 are: ");

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

            {

                Console.WriteLine(arr3[i]);

            }

            Console.WriteLine();

            Console.WriteLine("The subjects of Batch2 are: ");

            for (int i = 0; i < numsub; i++)

            {

                Console.WriteLine(sub3[i]);

            }

            Console.ReadLine();

        }


    }

No comments: