Ok I need to be pointed into the right area where I'm going

I seem to be lost and more I read it confuses me more.

My assignment is:
Create a C# project to process 10 students result. Use arrays to keep all the students details in terms of Student Id, full name, assignment marks, exam marks and total marks.

 Create a menu on the form with following items:

1. Enter student result
2. Calculate Total results of students
3. Display the results and Grade
4. Display the highest and lowest mark
5. Search for the result
6. Exit

 Write Method to implement every item in the above menu with the meeting of following requirements:

 Enter the results of every student for one assignment and one exam with the full mark 100 marks of each result, while the weight for both are 50%.
 Calculate the total result for every student (Total = A * 50% + Exam *50%);
 Display Student Id, all the results and grade for every student. The grade is based on the following rules:
 If total marks < 80 grade is F
 If total marks between 80 to 94 grade is P
 If total marks >=90 grade is M
 Also, the number of students in each grade will be counted;
 Display student Id, name and the result of the student who has the highest total marks and one who has lowest total marks;
 Display all the results of one student after the search by Student Id.

I dont want someone to do this for me but I want help in the right direction.

the code I have is

static void Main() 
		{
			Application.Run(new Form1());
		}

		int [] StudentID = new int[10];
		String[] Name = new String [10];
		int [] Result1 = new int [10];
		int [] Result2 = new int [10];

		void EnterStudent()
		{
			StudentID[0] = int.Parse(textBox1.Text);
				Name[0] = (textBox2.Text);
				Result1[0] = int.Parse(textBox3.Text);
				Result2[0] = int.Parse(textBox4.Text);
		{
			for ( int index = 0; index < 10; index++ );
			
			listBox1.Items.Add //I dont know how to get it to show the data		}

			
			}

		private void menuItem3_Click(object sender, System.EventArgs e)
		{
		EnterStudent();
		}

I want to have a menu to start it then you enter the student ID, name and results. Click on a button to save and write the next results for the next student but I'm confused about what to write in the button part. Also is what I've done right?

OK

The code you posted is partly confusing in regards to where your code appears to be - however, looking past that,

If you had made a class, you could have an array of that class, it would then hold the id, name and 2 results. rather than separate arrays for each.

As for your how to use the listbox, press F1 - when in doubt. It has examples. You're kind right but again if you did 1 class you could easily handle the what is displayed as your item.

How to use arrays is also well defined in your helpfile - but it looks like you have a start.

Ok I'd made a mess of the code and gotten past where I was.

static void Main() 
		{
			Application.Run(new Form1());
		}
		int count=0;
		int [] StudentID = new int[10];
		String[] Names = new String [10];
		decimal [] Result1 = new decimal [10];
		decimal [] Result2 = new decimal [10];
		//int High;
		//int Low;

		void Display()
		{
		
			listBox1.Clear();
			listBox1.Show();
			
			listBox1.Cloumns("StudentID", 50, HorizontalAlignment.Right);
			listBox1.Columns.Add("Names", 50, HorizontalAlignment.Left);
			listBox1.Columns.Add("Result1", 50, HorizontalAlignment.Center);
			listBox1.Columns.Add("Result2", 50, HorizontalAlignment.Center);
			
			
		}


		void EnterStudent()
			//Setup for entering student details

		{
			if (count <10)
			{
				StudentID[count] = int.Parse(textBox1.Text);
				Names[count] = (textBox2.Text);
				Result1[count] = decimal.Parse(textBox3.Text);
				Result2[count] = decimal.Parse(textBox4.Text);

				textBox1.Clear();
				textBox2.Clear();
				textBox3.Clear();
				textBox4.Clear();

				count ++;

				if (count == 10)
				{
					MessageBox.Show("No more students can be added");
				}
			}
			}
		
			
            
			
			

		private void menuItem3_Click(object sender, System.EventArgs e)
		{
		listBox1.Hide();
		}

		private void button2_Click(object sender, System.EventArgs e)
		//Enter Student Details
		{
		EnterStudent();
		}

		private void Form1_Load(object sender, System.EventArgs e)
		{
		
		}

		private void menuItem5_Click(object sender, System.EventArgs e)
		{
			Display();
		}

											   	
	}	
}

for some reason I can't get the columns to work and it doesn't like my .clear
I can't list the array

beforehand, sorry for my english...
for example, you can create a class Student where place info about student (such as ID, Name, Result1, Result2). To create an array of students, you can use (for example) ArrayList. It accept to add object in collection. I will appear you to list array. To extract info about specific student, you just have to convert it to Student.
To display such information I prefer to use dataGrid.

Which is what I already suggested Antenka

Of course ... but I see the second version of code, and there's no such changes, that you offered :) I decided to paraphrase it.

How do I display the array in a listbox?

ListBox.Items.Add(object element);

static void Main() 
		{
			Application.Run(new Form1());
		}
		int count = 0;
		int [] StudentID = new int[3];
		String[] Names = new String [3];
		decimal [] Result1 = new decimal [3];
		decimal [] Result2 = new decimal [3];
		decimal [] StudentTotal = new decimal [3];
		int HighestIndex = 0;
		decimal HighestMark = 0;
		int LowestIndex = 0;
		decimal LowestMark = 0;
		private StreamReader myReader;
		private StreamWriter myWriter;
			
		
		//Setup for entering student details
		void EnterStudent()
		{
			if (count <3)
			{
				StudentID[count] = int.Parse(textBox1.Text);
				Names[count] = (textBox2.Text);
				Result1[count] = decimal.Parse(textBox3.Text);
				Result2[count] = decimal.Parse(textBox4.Text);

				textBox1.Clear();
				textBox2.Clear();
				textBox3.Clear();
				textBox4.Clear();

				count ++;

				if (count == 3)
				{
					MessageBox.Show("No more students can be added");
				}
			}
		}
		//Setup for calculating the percent of grade out of 100
		void calculation()
		{
			decimal percent = 0.5M;
			for (int i = 0; i < StudentID.Length; i++)
			{
				StudentTotal[i] = (Result1[i] * percent) + (Result2[i] * percent);
				
			}
		}

		void Display()
		{
			decimal result;
			string grade = "I";
			//int [] StudentTotal = new int [3];

			listBox1.Show();
			listBox1.Items.Clear();

			for (int i = 0; i < StudentID.Length; i++)
			{
					
				result = StudentTotal[i];

				if (result == 0)
				{
					grade = "I";
				}
				else if (result < 80)
				{
					grade = "F";
				
				}
				else if (result <95)
				{
					grade = "P";
				
				}
				else
				{
					grade = "M";
				
				}
				
				listBox1.Items.Add("Student ID " + StudentID[i].ToString() + "   Name " + Names[i].ToString() + "   Assignment " + Result1[i].ToString() + "   Test " + Result2[i].ToString() + "   Grade " + grade);		 
			}
		}
		//Setup for student highest
		void Highest()
		{
			HighestMark = 0;
			HighestIndex = 0;
			
			for (int i = 0; i <StudentID.Length; i++)
			{
				if(StudentTotal[i] > HighestMark)
				{
					HighestMark = StudentTotal[i];
					HighestIndex = i;
				}
			}
		}
		//Setup for student lowest
		void Lowest()
		{
			LowestMark = 100;
			LowestIndex = 0;

			for(int i = 0; i <StudentID.Length; i++)
			{
				if(StudentTotal[i] <= LowestMark)
				{
					LowestMark = StudentTotal[i];
					LowestIndex = i;
				}
			}
		}
		//Displays highest and lowest Grade student
		void DisplayHighLow()
		{
			listBox1.Show();
			listBox1.ClearSelected();

			Lowest();
			Highest();

			listBox1.Items.Add("Lowest Student ID  " + StudentID[LowestIndex].ToString() + "  Name  " + Names[LowestIndex].ToString() + "  Assignment  " + Result1[LowestIndex].ToString() + "  Test  " + Result2[LowestIndex].ToString() + "  Mark  " + LowestMark.ToString());
			listBox1.Items.Add("Highest Student ID " + StudentID[HighestIndex].ToString() + "  Name  " + Names[HighestIndex].ToString() + "  Assignment  " + Result1[HighestIndex].ToString() + "  Test  " + Result2[HighestIndex].ToString() + "  Mark  " + HighestMark.ToString());
		}
		//search for Student ID
		void Search()
		{
			string search;
			bool found = false;
			search = textBox5.Text;
			listBox1.Show();
			listBox1.ClearSelected();
			
			for (int i = 0; i < StudentID.Length; i++)
			{
				
				if (search == StudentID[i].ToString())
				{
					listBox1.Items.Add("Student ID " + StudentID[i].ToString() + "  Name  " + Names[i].ToString() + "  Assignment  " + Result1[i].ToString() + "  Test  " + Result2[i].ToString());
				}
				found = true;
			}
			if (found == false)
			{
				MessageBox.Show("No Record");
			}
		}
		//Searches for range of results
		void Search2()
		{
			string search;
			bool found = false;
			search = textBox5.Text;
			listBox1.Show();
			listBox1.ClearSelected();
			
			for (int i = 0; i < StudentID.Length; i++)
			{
				
				if (search == StudentTotal[i].ToString())
				{
					listBox1.Items.Add("Student ID " + StudentID[i].ToString() + "  Name  " + Names[i].ToString() + "  Assignment  " + Result1[i].ToString() + "  Test  " + Result2[i].ToString());
					found = true;
				}
				
			}
			if (found == false)
			{
				MessageBox.Show("No Record");
			}
		}
		//Setup for reading "student.txt"
		void Read()
		{		
			if (myReader != null)
			{
				myReader.Close();
			}
			myReader = new StreamReader("student.txt");
			listBox1.Show();
			listBox1.Items.Clear();
			for (int i = 0; i < StudentID.Length; i++)
			{
				while (myReader.Peek() != -1)
				{
					StudentID[i] = int.Parse(myReader.ReadLine());
					Names[i] = myReader.ReadLine();
					Result1[i] = int.Parse(myReader.ReadLine());
					Result2[i] = int.Parse(myReader.ReadLine());
					StudentTotal[i] = int.Parse(myReader.ReadLine());
					

					listBox1.Items.Add("ID " + StudentID[i].ToString() + "  " + "Name " + Names[i] + "  " + "Assignment " + Result1[i].ToString() + "  " + "Test " + Result2[i]); 
				}		
			}
			myReader.Close();
		}
		//Setup for writing to "student.txt"
		void Write()
		{
			for (int i = 0; i < StudentID.Length; i++)
			{
				myWriter.WriteLine (StudentID[i]);
				myWriter.WriteLine (Names[i]);
				myWriter.WriteLine (Result1[i]);
				myWriter.WriteLine (Result2[i]);
				myWriter.WriteLine (StudentTotal[i]);
			}
			myWriter.Close();
			MessageBox.Show("Information Saved");
		}
		

		//Setup for password form
		private void Password()
		{
			Form2 myF = new Form2();
			Form1.ActiveForm.Hide();
			myF.Show();
		}
		//Setup for time and date
		private void Time1_Tick(object sender, System.EventArgs e)
		{
			time.Text = DateTime.Now.ToShortTimeString();
			date.Text = DateTime.Now.ToShortDateString();
		}
		//Setup for time and date to display on form
		private void Form1_Load(object sender, System.EventArgs e)
		{
			MessageBox.Show("Welcome to the student result system", "Catherine Dally");
			listBox1.Hide();
			time.Text = DateTime.Now.ToShortTimeString();
			date.Text = DateTime.Now.ToShortDateString();
		}
		//Setup for entering student data	
		private void button1_Click(object sender, System.EventArgs e)
		{
			listBox1.Hide();
			EnterStudent();
		}
		//setup for Display
		private void menuItem4_Click(object sender, System.EventArgs e)
		{
			listBox1.Show();
			Display();
			myWriter = new StreamWriter ("student.txt");
			
		}
	//Setup for password
		private void menuItem2_Click(object sender, System.EventArgs e)
		{
			listBox1.Hide();
			Password();
		}
		//Setup for displaying calculation
		private void menuItem3_Click(object sender, System.EventArgs e)
		{
			listBox1.Show();
			calculation();
			Display();
		}
		//Setup for Displaying highest and lowest student details
		private void menuItem5_Click(object sender, System.EventArgs e)
		{
			listBox1.Items.Clear();
			DisplayHighLow();
		}
		//Setup for displaying the file for read
		private void menuItem7_Click(object sender, System.EventArgs e)
		{
			Read();
		}
		//Setup for the exit button
		private void button2_Click(object sender, System.EventArgs e)
		{
			this.Close();
			MessageBox.Show("The time is " + DateTime.Now.ToShortTimeString());
			MessageBox.Show("Thank you, Have a nice day");
		}
		//Showing the listbox for Search
		private void menuItem6_Click(object sender, System.EventArgs e)
		{
			listBox1.Items.Clear();
		}
		//Setup for the button to work for search
		private void button3_Click(object sender, System.EventArgs e)
		{
			listBox1.Show();
			Search();
		}
		//Setup for the writer to write to file "student.txt"
		private void menuItem9_Click(object sender, System.EventArgs e)
		{
			myWriter = new StreamWriter("student.txt");
			Write();
		}
		//Setup for reading the file "student.txt"
		private void menuItem10_Click(object sender, System.EventArgs e)
		{
			Read();
		}
		//Setup for printing
		private void menuItem14_Click(object sender, System.EventArgs e)
		{
			//Print
			printDocument1.Print();
		}
		//Exit
		private void menuItem12_Click(object sender, System.EventArgs e)
		{
			this.Close();
			MessageBox.Show("Thank you, Have a nice day");
		}
		//Showing form 3 for the About menu
		private void menuItem11_Click_1(object sender, System.EventArgs e)
		{
			Form3 myF = new Form3();
			Form1.ActiveForm.Hide();
			myF.Show();
		}
		//Setup for Searching for the range
		private void button4_Click(object sender, System.EventArgs e)
		{
		Search2();
		}
		//Setup for the printer
		private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
		{		
			Font pf = new Font("Arial", 12);
			Font hf = new Font("Arial", 14, FontStyle.Bold);

			float h = pf.GetHeight();
			float x = e.MarginBounds.Left;
			float y = e.MarginBounds.Top;
			string p;
			p= "\t\t\t" + "Student.txt";
			e.Graphics.DrawString(p, hf, Brushes.Black, x ,y);
			y = y + h * 2;
			for (int i = 0; i <= listBox1.Items.Count - 1; i++)
			{
				p = listBox1.Items[i].ToString();
				e.Graphics.DrawString(p, pf, Brushes.Black, x ,y);
				y = y + h;
			}
		
		}
		//Directing the button Print to the Printer
		private void button5_Click(object sender, System.EventArgs e)
		{
		printDocument1.Print();
		}
		//Exit
		private void menuItem13_Click(object sender, System.EventArgs e)
		{
			this.Close();
			MessageBox.Show("The time is " + DateTime.Now.ToShortTimeString());
			MessageBox.Show("Thank you, Have a nice day");
		}
	}
}

Can someone help with why I can get search2 working
It comes up with a false everytime
Its meant to search for the total of both assignment and grade /2 so they're 100% overall or less

But your search2 only asks "if (search == StudentTotal.ToString())" debug it watch the values. This will hold the answer

I worked it out it was fine just wanting a decimal and not an int when in the program. Thanks

hi, im at college also and seems like were making similar sort of programs, we started in command line applications tho not visual, anyway could you not do a [10,4] multi-dimensional array and do a for loop for (loop = 0; loop < 10; loop++) {} and then inside the method brackets just declare each piece of data into its specified place in the array like say student names as 0,0 - 9,0, then student mark 1,1 -9,1. Not realy sure how else to explain multi-dimensional arrays but if u need a better explanation just ask :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.