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

Project 2-Using Microsoft Visual C# This project will use the program from proje

ID: 3735831 • Letter: P

Question

Project 2-Using Microsoft Visual C# This project will use the program from project one. Two methods will be added in this project to the program. The class for the first name, last name, total points and percent will be used. This class will be used as an array and will be used to write the data to a file. The first method will sort the last name of the class array in alphabetical order. The second method will generate a report of the items in the array Processing main method In a loop until the user indicates no more students: Prompt the user for the student's first name Prompt the user for the student's last name In a loop: Prompt the user to enter cach of the grades Add each of the grades to the total grade Endloop Call method of class to calculate percentage pass total possible(400) Display the student name, total grade and the percentage Prompt the user if there are more students Endloop Call method to generate the report Write all records to a binary file Call method to sort by last name Call method to gencrate the report End of main function For all calls to functions pass the class array and the number of elements in the array Class CourseGrads Data members Student First Name, Student Last Name Total Grade Final Percent Mcthods Constructor No code Calculate Percent Perccnt as calculated by Total Grade dixidsd by Total possible (400) times 100 create property (get/set) processing for the 4 data members

Explanation / Answer

Copy the following code to and editor.

Please Note: Validations not included

using System;

namespace Chegg1
{
class Program
{
static void Main(string[] args)
{
CourseGrade[] grades = new CourseGrade[10];
int proceed;
int count = 0;
do
{
CourseGrade courseGrade = new CourseGrade();
Console.WriteLine(" Enter Student's First Name");
courseGrade.FirstName = Console.ReadLine();
Console.WriteLine(" Enter Student's Last Name");
courseGrade.LastName = Console.ReadLine();
int gradeCounter = 0;
int totalGrade = 0;
int gradeProceed;
do
{
Console.WriteLine(" Enter the grade");
//Enter a proper integer number;
int grade = int.Parse(Console.ReadLine());
totalGrade = totalGrade + grade;
gradeCounter++;
Console.WriteLine(" Do you want to enter more grades 1. Yes. 2. No");
gradeProceed = int.Parse(Console.ReadLine());
} while (gradeProceed == 1 && totalGrade < 400);

courseGrade.TotalGrade = totalGrade;
courseGrade.FinalPercent = courseGrade.CalculatePercent(totalGrade,gradeCounter);
Console.WriteLine(" Details");
Console.WriteLine(" Student Name : {0} {1}", courseGrade.FirstName, courseGrade.LastName);
Console.WriteLine(" Total Grade : "+ courseGrade.TotalGrade);
Console.WriteLine(" Percentage : "+ courseGrade.FinalPercent);
Console.WriteLine(" Do you want to enter more student details? 1. Yes. 2. No");
proceed = int.Parse(Console.ReadLine());
grades[count] = courseGrade;
count++;
} while (proceed == 1);
CourseGrade courseGrade1 = new CourseGrade();
grades = courseGrade1.SortLastName(grades, count);
courseGrade1.PrintDetails(grades, count);
Console.ReadKey();
}
}
public class CourseGrade
{
public string FirstName { get; set; }
public string LastName { get; set; }
public int TotalGrade { get; set; }
public decimal FinalPercent { get; set; }
public CourseGrade()
{

}
public decimal CalculatePercent(int totalGrade, int count)
{
return (decimal)(totalGrade * 100) / 400;// same as of ((grade/ total grade)* 100)
}
public CourseGrade[] SortLastName(CourseGrade[] arr, int length)
{
for (int j = 1; j <= length; j++)
{
int swapCount = 0;
for (int i = 0; i < length - j; i++)
{
if (string.Compare(arr[i+1].LastName, arr[i].LastName, true) < 0) //if first number is greater then second then swap
{
CourseGrade temp = arr[i];
arr[i] = arr[i + 1];
arr[i + 1] = temp;
swapCount++;
}
}
if (swapCount == 0)
{
return arr;
}
}
return arr;
}
public void PrintDetails(CourseGrade[] arr, int length)
{
Console.WriteLine(" Name Total Pet ");
Console.WriteLine("---- ----- --- ");
for (int i=0;i<length;i++)
{
Console.WriteLine(arr[i].LastName + " "+ arr[i].FirstName);
Console.Write(" "+ arr[i].TotalGrade);
Console.Write(" " + arr[i].FinalPercent);
Console.WriteLine(" ");
}
}
}
}