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.