Hi there, I'm a bit of a newbie when it comes to C# and only had previous experience with Visual Basic. The problem i'm having revolves around a program I need to create too look at Students marks, the idea is the user inputs the marks and to end the program they press -1.
Now, I have that sorted but the final part requires me to sort grades out by categorising them into A, B, C etc by adding 1 to the grade variable. I have tried If statements but it doesn't seem to work, I can't use "if Marks[count]" because it says it's out of the current context. Here is the code I have so far;
System.Console.WriteLine("\t\t\t\t Student Results Analyser ");
System.Console.WriteLine("\t\t\t\t ------------------------ ");
System.Console.WriteLine();
int[] Marks = new int[100];
System.Console.Write("Please enter a mark or -1 to finish> ");
string NumberAsString = System.Console.ReadLine();
int mark = Convert.ToInt32(NumberAsString);
int numberOfMarksInput = 0;
while (mark != -1)
{
Marks[numberOfMarksInput] = mark;
numberOfMarksInput++;
System.Console.Write("Please enter a mark or -1 to finish> ");
NumberAsString = System.Console.ReadLine();
mark = Convert.ToInt32(NumberAsString);
}
System.Console.WriteLine();
System.Console.WriteLine("\t\t\t\t Results ");
System.Console.WriteLine("\t\t\t\t ------- ");
System.Console.WriteLine();
System.Console.WriteLine("Total amount of marks entered > {0}", numberOfMarksInput);
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
int f = 0;
Can anyone give me an idea on how I can achieve this? It's completely stumped me.
Thankyou for any help you can give me.