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

CAN YOU HELP ME WITH THIS PLEASE IT IS AN EMERGENCY!!! I WANT TO WRITE THE FOLLO

ID: 3825304 • Letter: C

Question

CAN YOU HELP ME WITH THIS PLEASE IT IS AN EMERGENCY!!!

I WANT TO WRITE THE FOLLOWING PROGRAM IN C# CONSOLE BY LOADING ARRAYS FROM THIS FILE. THE ARRAYS ARE LOAD STARTING FROM THE SECOND LINE AND SO ON;

C# CONSOLE PLEASE!!

QUESTION:

Sort by Name and then Display the Student’s Name and Grade

              Your Choice of Sort methods    

Using a coded search routine, sort names (and their associated grades) in alphabetic order by name and then display the names and grades in a list with headers (each name and grade outputs on a separate line).

Little Record2 Notepad File Edit Format View Help 20,00 Ann,5 DONNA, 24 REX,377 SUSAN,63 JOHNNY,0 KALEB, 69 CAROL, 66 TONY,11 FRANK ,4 BOBBI,0 Henry ,87 Bob, 77 Diane, 87 Paula ,90 George, 94 Larry,89 Sarah 77 Maggie,99 Pat, 54 Howard,87 Type here to search 00 PM 4/21/2017 L

Explanation / Answer

// Source Code to sort the name alphabeticallyand display their relevant grades accordingly

namespace arrange
{
    class NamGradSort
    {
        public static List<Student> st = new List<Student>(); //list object

        static void Main(string[] args)
        {
            st.Add(new Student("Ann", 5));
            st.Add(new Student("Donna", 24));
            st.Add(new Student("Rex", 377));
            st.Add(new Student("Susan", 63));
            st.Add(new Student("Johnny", 0));
            st.Add(new Student("Kaleb", 69));
            st.Add(new Student("Carol", 66));
            st.Add(new Student("Tony", 11));
            st.Add(new Student("Frank", 4));
            st.Add(new Student("Bobbi", 0));
            st.Add(new Student("Henry", 87));
            st.Add(new Student("Bob", 77));
            st.Add(new Student("Diane", 87));
            st.Add(new Student("Paula", 90));
            st.Add(new Student("George", 94));
            st.Add(new Student("Larry", 89));
            st.Add(new Student("Sarah", 77));
            st.Add(new Student("Maggie", 99));
            st.Add(new Student("Pat", 54));
            st.Add(new Student("Howard", 87));

            sortOnGrade sog = new sortOnGrade();
            st.Sort(sog);
            foreach (Student n in st)
            {
                Console.WriteLine(n.name);
            }
            Console.ReadLine();
                  
        }
    }

    public class Student:IComparable<Student>
    {
        public string name;
        public int grade;
        public Student(string name, int grade)
        {
            this.name = name;
            this.grade = grade;
        }
        public int CompareTo(Student b)
        {
            // Alphabetic sort name[A to Z]
            return this.name.CompareTo(b.name);
        }
   
    }

    public class sortOnGrade : IComparer<Student>
    {
        public int Compare(Student a, Student b)
        {
            if (a.grade > b.grade) return 1;
            else if (a.grade < b.grade) return -1;
            else return 0;
        }
    }
}

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