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

how we should code this in c#!! Student Grade Graph by Passing in Command Line A

ID: 3795245 • Letter: H

Question

how we should code this in c#!!

Student Grade Graph by Passing in Command Line Arguments In this assignment, you’re going to create a console app for a teacher who has an unknown number of students and needs to display a graph of student grades. many different ways of coding C# Console apps. This is how you’ll get the grades into the app. You’re going to pass in grades through the command line separated by spaces. There can be as many grades as the teacher wants to send to the program. You’ll put the grades into the following ranges: A [90-100], B [80-89], C [70-79], D [60-69] and F [Below 60] On the Y axis, you’ll have the number of grades. Figure out which grade has the most and make that the highest value for the Y axis. You’ll display a bar graph with asterisks for the graph bars that shows the grade distribution. The X-axis will be the grades A to F. You’ll then tell the user how many of each grade there were. 2 Here is a screen shot example using the following values: 83 72 100 49 66 88 84 75 92 96 50 77 93 82 89 99 97 94 86 You’ll prompt the user to press the enter key to end the program and exit after displaying their grades. Assume proper input for the grades and that the user will pass in grades between (and including) 0 and 100. Here is another set of values: 99 55 14 96 70 82 75 83 45 96 74 77 86 84 100 96 86 82 83 84 72 86 85 74 71 90 84 73 77 96 84 84 76 75

these are the set of: NumbersToTest.txt

Explanation / Answer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
class Program
{
static bool ReadInteger(out int k)
{
string input = System.Console.ReadLine();
k = 0;
try
{
k = Convert.ToInt32(input);
return true;
}
catch (System.Exception ex)
{
System.Console.WriteLine("Error in the input format ");
return false;
}
  

}

static void Main(string[] args)
{
Console.WriteLine("enter the number of student");
int mar = 0;
mar = Convert.ToInt32(Console.ReadLine());
int MAX_SUBJ = mar;

int[] arrMark = new int[MAX_SUBJ];
string grade = "";

for (int i = 0; i < MAX_SUBJ; i++)
{
System.Console.Write("Enter student{0} Mark: ", i + 1);
ReadInteger(out arrMark[i]);
}
System.Console.Write(" No Mark Grade ");

for (int i = 0; i < MAX_SUBJ; i++)
{
if (arrMark[i] > 100)
grade = "Error";
else if (arrMark[i] > 90)
grade = "A";
else if (arrMark[i] > 80)
grade = "B";
else if (arrMark[i] > 70)
grade = "C";
else if (arrMark[i] > 60)
grade = "D";
else
grade = "F";
System.Console.Write("student marks {0} {1} {2} ", i + 1, arrMark[i], grade);
  
}
Console.ReadLine();
}
}
}

Output

enter the number of student
6
Enter student1 Mark: 45
Enter student2 Mark: 65
Enter student3 Mark: 78
Enter student4 Mark: 97
Enter student5 Mark: 78
Enter student6 Mark: 45


No Mark Grade
student marks 1 45 F
student marks 2 65 D
student marks 3 78 C
student marks 4 97 A
student marks 5 78 C
student marks 6 45 F