Write a program that will produce a report showing the current and max-imum enrollments for a number of classes. Your applications should be designed with two classes. The first class should include data members for the name of the course, current enrollment, and maximum enroll-ment. Include an instance method that returns the number of students that can still enroll in the course. The ToString() method should return the name of the course, current enrollment, and the number of open slots. In the implementation class, declare parallel arrays and do a compile-time initialization for the name of the course, current enroll-ment, and maximum enrollment. Also declare an array of class objects in your implementation class. Test your application with the following data:

Class name Current enrollment Maximum enrollment
CS150 180 200
CS250 21 30
CS270 9 20
CS300 4 20
CS350 20 20

Respuesta :

Answer:

Check the explanation

Explanation:

CODE

using System;

using System.Collections.Generic;

using System.Text;

using System.Runtime.InteropServices;

namespace listofcourses

{

   class Course1

   {

       public string coursename;

       public int courseenrol;

       public int maximum;

   }

   class Courses1

   {

       public List<Course1> colist = new List<Course1>();

       public int coursemaximum;

       public int addRecord(string num, int err,int maximum)

       {

           Course1 c1 = new Course1();

           c1.coursename = num;

           c1.courseenrol = err;

           c1.maximum=maximum;

           colist.Add(c1);

           coursemaximum = colist.Count;

           return 1;

       }

   }

class Implement

{  

static public Courses1 cos = new Courses1();

static public void printrecord()

{

           Console.WriteLine("_______________________________________________________________");

Console.WriteLine("SNo Class Name       currentEnroll MaximumEnroll");

           Console.WriteLine("_______________________________________________________________");

for (int i = 0; i < cos.coursemaximum; i++)

{

     Console.Write("{0, -5}", i + 1);

     Console.Write("{0, -19}", cos.colist[i].coursename);

     Console.Write("{0, -7}", cos.colist[i].courseenrol);

     Console.Write("{0, -7}", cos.colist[i].maximum);

     Console.WriteLine();

}

          Console.WriteLine("_______________________________________________________________");

}

static public void getRecords()

{

     Console.Write("please enter Course Name: ");

     string num;

     int c1,m1;

     num = Console.ReadLine();

            Console.Write("Enter current enrollment");

           c1= Convert.ToInt32(Console.ReadLine());

           Console.Write("Enter maximum enrollment");

           m1= Convert.ToInt32(Console.ReadLine());

     cos.addRecord(num,c1,m1);

}      

static void Main(string[] args)

{

     Console.WriteLine("Course Enrollment");

     Console.Write("please Enter the number of courses: ");

     int ncval = -1;

     string xval = Console.ReadLine();

     ncval= Convert.ToInt32(xval);

      for (int i = 1; i <= ncval; i++)

     {

           Console.WriteLine("\nEnter " + i.ToString() + " course enrollment\n");

           getRecords();

     }

    printrecord();

     char k1 = Console.ReadKey().KeyChar;

}

}

Kindly check the code output below.

Ver imagen temmydbrain