For this task you are given a partially-complete program- a program designed to show the number of enrolment positions open for each class, or display that the class is full if that is the case.

To finish this program, you must finish the DisplayClassEnrolment method.

The completed method should first display the text "Number of places still available for each class." followed by a blank line. Following this blank line, it should display one line of text for each class. That line should be of the following format:

"(class name) has (number of places left) places left."

The number of places left in each class is the maximum enrolment minus the current enrolment. If there are no places left (the current enrolment is the same as the maximum enrolment) this line should instead be displayed:

"(class name) is full."

A framework has been provided for your convenience in writing the program. The comments direct you to where you should insert your own code.

It is important that you display the exact same messages as in the example. If your program displays something else you may fail the exercise even if your program calculates the class enrolment correctly.

Sample code:

/* This program uses three parallel
* arrays to display the class name
* and how many places are left in that
* class.
*/
using System;

namespace ClassEnrolment {

class ClassEnrolment {

public static void Main() {
// A single test case is provided here for you, but you should consider trying some other test cases.
string[] classNames = new string[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" };
int[] currentEnrolments = new int[] { 13, 8, 17, 16, 8 };
int[] maximumEnrolments = new int[] { 29, 23, 29, 22, 27 };

DisplayClassEnrolment(classNames, currentEnrolments, maximumEnrolments);

ExitProgram();
}

/// < summary>
/// Displays the number of places still available in an array of classes.
/// < /summary>
/// < param name="classNames">Names of the classes< /param>
/// < param name="currentEnrolments">Current enrolment in the classes, in an array aligned to classNames< /param>
/// < param name="maximumEnrolments">Maximum enrolment possible in the classes, in an array aligned to classNames< /param>
public static void DisplayClassEnrolment(string[] classNames, int[] currentEnrolments, int[] maximumEnrolments) {
Console.WriteLine("Number of places still available for each class.n");
// Write a "for" loop here, using the className.Length property.
// ...
// ...
// ...
}

/// < summary>
/// Prompts the user to press 'enter' to exit and waits for this.
/// < /summary>
public static void ExitProgram() {
Console.Write("Press enter to continue ...");
Console.ReadLine();
}
}
}
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.