Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help in Visual Studio C-sharp : Create a C# class named Course . The Course

ID: 3793215 • Letter: N

Question

Need help in Visual Studio C-sharp :

Create a C# class named Course. The Course class should have the following properties: Note: Name each property with the first letter in upper-case and the first letter of each successive concatenated words also in upper case, as shown below).

CourseID as int

CourseCode as string

Title as string

CreditHour as int

DeptCode as string

Develop a single constructor and a method as described below:

Constructor: Provide only one constructor where the user will pass all property values while constructing a course object.

Override the inherited ToString() method and return a formatted string so that a statement like Console.WriteLine(c1.ToString()); displays a course object’s information as shown below:

Hints, in the inherited ToString() method should return a string as follows:

Explanation / Answer

using System.IO;
using System;
class Course{
int CourseID ;
string CourseCode ;
string Title ;
int CreditHour ;
string DeptCode ;
public Course(int id, string code, string t, int h, string d){
CourseID = id;
CourseCode = code;
Title = t;
CreditHour = h;
DeptCode = d;
}
// Override the ToString method:
public override string ToString()
{
string CourseDesc =
String.Format(" {0} {1} {2} {3} {4}", CourseID,CourseCode,Title, CreditHour, DeptCode);
return CourseDesc;
}
}
class Program
{
static void Main()
{
Course c = new Course (111,"CSE", "Computer Science",4, "CSEDEPT");
Console.WriteLine(c.ToString());
}
}

Output:

sh-4.3$ mcs *.cs -out:main.exe                                                                                                                                                                                                                                         

sh-4.3$ mono main.exe                                                                                                                                                                                                                                                  

        111     CSE     Computer Science        4       CSEDEPT

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote