C# Programming Platform II Sorting Basics Assignment For this assignment you need to do the following: Step 1: Create a console application named yourname_sortingbasics. Make sure that you use a...

1 answer below »
See the attachment.


C# Programming Platform II Sorting Basics Assignment For this assignment you need to do the following: Step 1: Create a console application named yourname_sortingbasics. Make sure that you use a windows classic desktop console application/.Net Framework console application and not a .Net Core console application. Step 2: Create a Student class that has the following: a. StudentID, LastName, FirstName, CourseID and Course Grade properties. b. A constructor that collects the above property information. c. A method that retrieves test data for this Student class. This method will use the following code for testing purposes: public static List getTestStudents() { // For testing purposes some duplicate student infomation will be used. List students = new List students = Student.getTestStudents(); Console.WriteLine(Student.SortTitle("Not Sorted")); Console.WriteLine(Student.ColumnHeader()); foreach (Student student in students) { Console.WriteLine(student); } Console.WriteLine("\nPress to quit..."); Console.ReadKey(); You should see a data dump on the test student data similar to the following: Note: Google string format operations to see what options you have in terms of using right hand justification, left hand justification, PadLeft, PadRight, etc. Step 4: Modify your Student class to add a default last name, first name sort capability. The IComparable interface is used typically to compare the current class instance with other instances of the same type. To use this technique, you would add to the Student class the IComparable interface: public class Student : IComparable The compiler will then warn you that you need to implement the interface member CompareTo. Now implement the CompareTo method to allow sorting by last name and then first name. Note: when doing name comparisons you usually uppercase all of the string characters first before processing the sort options. Thus make sure you UpperCase first and last name so that no sort differences with occur based on case differences. Bill Gates versus bill Gates or bill gates. 10 points are scored if you correctly implement the CompareTo method to provide this last name, first name sort capability. To test your CompareTo method in your main method add the following code: // Sort using built in Student IComparer default sort... Console.WriteLine(Student.SortTitle("Sorted by Last Name and First Name Using Built in IComparable")); Console.WriteLine(Student.ColumnHeader()); students.Sort(); foreach (Student s in students) { Console.WriteLine(s); } Your console screen should then show the following: Note: Original data is preserved. However, you can output upper cased string data if you wish. Step 5: Now let’s examine the common situation of multiple sorts done on multiple sort fields. The IComparer interface is used when you want to compare 2 objects of the same type. It can be implemented with nested classes or separate external classes. As an example let’s set up a separate class called StuSortCourseGradeLastFirst that provides sorting capability on course grade, then last name and first name: Points scored for implementing correctly a sort by course grade, last name and then first name: 10 points To test this sort add the following code to your Main method: Console.WriteLine(Student.SortTitle("Sorted by Course Grade, Last Name, and then First Name Using IComparer")); Console.WriteLine(Student.ColumnHeader()); students.Sort(new StuSortCourseGradeLastFirst()); foreach (Student s in students) { Console.WriteLine(s); } Step 6: Now let’s sort your students by Last Name, First Name and then CourseID with another sort class such as StuSortLastFirstCourseID. Points: 10 Step 7: Finally let’s sort your students by Last Name, First Name and then CourseID and then CourseGrade you would just add another sort class such as StuSortLastFirstCourseIDCourseGrade. Points: 10 Step 8: Save your work and run your application! When you finish your project put your zipped project in the UCLA Module 2 application submission area. Remember that I need to run your project from my machine so make sure your zipped project folder contains all of your work. Also note that we are not using LINQ, SQL or Lambda expressions yet for a sorting technique. When we examine functional programming, you are going to find that sorting becomes an extremely simple operation. Total points for this project: 50 (10 points for each sort condition for a total of 4 sorts) with the remainder of the points being distributed based upon project functionality, report formatting, coding style, etc.
Answered Same DayJul 07, 2021

Answer To: C# Programming Platform II Sorting Basics Assignment For this assignment you need to do the...

Shweta answered on Jul 07 2021
143 Votes
87635/FloWang_sortingbasics/.vs/FloWang_sortingbasics/v16/.suo
87635/FloWang_sortingbasics/FloWang_sortingbasics/App.config




87635/FloWang_sortingbasics/FloWang_sortingbasics/bin/Debug/FloWang_sortingbasics.exe
87635/FloWang_sortingbasics/FloWang_sortingbasics/bin/Debug/FloWang_sortingbasics.exe.config




87635/FloWang_sortingbasics/FloWang_sortingbasics/bin/Debug/FloWang_sortingbasics.pdb
87635/FloWang_sortingbasics/FloWang_
sortingbasics/FloWang_sortingbasics.csproj



Debug
AnyCPU
{259A06CF-19E4-48B8-9422-2092378C4F29}
Exe
FloWang_sortingbasics
FloWang_sortingbasics
v4.7.2
512
true
true


AnyCPU
true
full
false
bin\Debug\
DEBUG;TRACE
prompt
4


AnyCPU
pdbonly
true
bin\Release\
TRACE
prompt
4























87635/FloWang_sortingbasics/FloWang_sortingbasics/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs
//
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
87635/FloWang_sortingbasics/FloWang_sortingbasics/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
87635/FloWang_sortingbasics/FloWang_sortingbasics/obj/Debug/FloWang_sortingbasics.csproj.CoreCompileInputs.cache
99bb595c81642432ace7375b95e0d409afb2bc9e
87635/FloWang_sortingbasics/FloWang_sortingbasics/obj/Debug/FloWang_sortingbasics.csproj.FileListAbsolute.txt
C:\Users\Acer\source\repos\FloWang_sortingbasics\FloWang_sortingbasics\obj\Debug\FloWang_sortingbasics.csprojAssemblyReference.cache
C:\Users\Acer\source\repos\FloWang_sortingbasics\FloWang_sortingbasics\obj\Debug\FloWang_sortingbasics.csproj.CoreCompileInputs.cache
C:\Users\Acer\source\repos\FloWang_sortingbasics\FloWang_sortingbasics\bin\Debug\FloWang_sortingbasics.exe.config
C:\Users\Acer\source\repos\FloWang_sortingbasics\FloWang_sortingbasics\bin\Debug\FloWang_sortingbasics.exe
C:\Users\Acer\source\repos\FloWang_sortingbasics\FloWang_sortingbasics\bin\Debug\FloWang_sortingbasics.pdb
C:\Users\Acer\source\repos\FloWang_sortingbasics\FloWang_sortingbasics\obj\Debug\FloWang_sortingbasics.exe
C:\Users\Acer\source\repos\FloWang_sortingbasics\FloWang_sortingbasics\obj\Debug\FloWang_sortingbasics.pdb
87635/FloWang_sortingbasics/FloWang_sortingbasics/obj/Debug/FloWang_sortingbasics.csprojAssemblyReference.cache
87635/FloWang_sortingbasics/FloWang_sortingbasics/obj/Debug/FloWang_sortingbasics.exe
87635/FloWang_sortingbasics/FloWang_sortingbasics/obj/Debug/FloWang_sortingbasics.pdb
87635/FloWang_sortingbasics/FloWang_sortingbasics/Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FloWang_sortingbasics
{
class Program
{
//Main method to call all the classess with sorted and non sorted data.
static void Main(string[] args)
{
List students = Student.getTestStudents();
Console.WriteLine(Student.SortTitle("Not Sorted\n"));
Console.WriteLine(Student.ColumnHeader());
foreach (Student student in students)
{
Console.WriteLine(student);
}

Console.WriteLine("\n\n");
Console.WriteLine(Student.SortTitle("Sorted by Last Name and First Name Using Built in IComparable\n"));
Console.WriteLine(Student.ColumnHeader());
students.Sort();
foreach (Student s in students)
{
Console.WriteLine(s);
}
Console.WriteLine("\n\n");
Console.WriteLine(Student.SortTitle("Sorted by Course Grade, Last Name, and then First Name Using ICompare\n"));
Console.WriteLine(Student.ColumnHeader());
students.Sort(new StuSortCourseGradeLastFirst());
foreach (Student s in students)
{
Console.WriteLine(s);
}
Console.WriteLine("\n\n");
Console.WriteLine(Student.SortTitle("Sorted by Last Name, First Name, and then Course ID Using IComparer\n"));
Console.WriteLine(Student.ColumnHeader());
students.Sort(new StuSortLastFirstCourseID());
foreach (Student s in students)
{
Console.WriteLine(s);
}
Console.WriteLine("\n\n");
Console.WriteLine(Student.SortTitle("Sorted by Last Name, First Name,...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here