Question
for the following question when running the code it showing the following errors kindly edit the code to recive the correct result Your task is
for the following question when running the code it showing the following errors kindly edit the code to recive the correct result
Your task is to complete the 'for' loop for the provided class enrolment program.
ANS
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace ClassEnrolment { class Program
{ static void Main(string[] args) { 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();
}
public static void DisplayClassEnrolment(string[] classNames, int[] currentEnrolments, int[] maximumEnrolments) { Console.WriteLine("Number of places still available for each class. ");
//For loop
for (int i = 0; i 0) { Console.WriteLine(classNames[i] + " has " + placesLeft + " places left. "); } else if (placesLeft == 0) { Console.WriteLine(classNames[i] + " is full. "); } } }
public static void ExitProgram() { Console.Write("Press enter to continue ..."); Console.ReadLine(); } } }
Errors shown when output run
Your DisplayClassEnrolment method printed an unexpected number of lines. For 5 classes we expected 6 (non-empty) lines of output including the header. You printed 1 lines. Your DisplayClassEnrolment method printed an unexpected number of lines. For 4 classes we expected 5 (non-empty) lines of output including the header. You printed 1 lines. Your DisplayClassEnrolment method printed an unexpected number of lines. For 7 classes we expected 8 (non-empty) lines of output including the header. You printed 1 lines.
+--------------+ | Test output: | +--------------+ Total score available for this exercise: 100
1 - Simple cases. (30 points) Test failed
2 - Full & not full. (35 points) Test failed
3 - Full & not full. (35 points) Test failed
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. Ifyour program displays something else you may fail the exercise even if your program calculates the class enrolment correctly If you still have difficulties, here are some tips when writing programs for AMS: Do not write your program directly into the text box. You should copy and paste the sample code into Visual Studio, write your program there, run it and test it to make sure it works, then paste it into AMS. You only get a limited number of attempts at each AMS exercise, so make sure they count. . If your code uses Console.ReadKey); it should be replaced with Console.ReadLine();. ReadKey () will work in Visual Studio but not in AMS Make sure your code displays exactly what the problem asks you for. If you can, copy and paste the text you need to display into your function to avoid possible transcription errors. If there are any mistakes at all your c ode will not pass. Sample code: / This program uses three parallel * arrays to display the class name * and how many places are left in that * class using System; 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. Ifyour program displays something else you may fail the exercise even if your program calculates the class enrolment correctly If you still have difficulties, here are some tips when writing programs for AMS: Do not write your program directly into the text box. You should copy and paste the sample code into Visual Studio, write your program there, run it and test it to make sure it works, then paste it into AMS. You only get a limited number of attempts at each AMS exercise, so make sure they count. . If your code uses Console.ReadKey); it should be replaced with Console.ReadLine();. ReadKey () will work in Visual Studio but not in AMS Make sure your code displays exactly what the problem asks you for. If you can, copy and paste the text you need to display into your function to avoid possible transcription errors. If there are any mistakes at all your c ode will not pass. Sample code: / This program uses three parallel * arrays to display the class name * and how many places are left in that * class using SystemStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started