1 Replies - 318 Views - Last Post: 14 April 2013 - 08:57 PM Rate Topic: -----

#1 magda6347  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 27-October 12

I am receiving a parsing error I believe I am missing a bracket

Posted 14 April 2013 - 08:38 PM

hello I believe I'm missing a bracket or have an extra one somewhere in my code and have been messing around with this for over 2 hours and think I'm only hurting my situation. I'm receiving 8 errors; line 37= unexpected while symbol in class. stuct. or interface ember declaration. line 44= unexpected symbol { in class struct, line 45= unexpected ) symbol, 56 = unexpected symbol int, 68= parsing error. Again I have been adding and removing brackets and parenthesis and nothing has helped my situation. I would appreciate any input thank you!


using System.IO;

namespace IntroCS
{
	class GradeFiles
	{

		public static void Main(string[] args)
		{

			
			string fileName = UIF.PromptLine ("Please enter the comp course with no spaces: ");
			string categoryFileName = "categories_" + fileName + ".txt";
			var reader = new StreamReader (categoryFileName);
			
			string input = reader.ReadLine();
			string[]category  = input.Split(',');
			for(i = 0; i < category.Length; i++)
				category[i] = category [i].Trim();
			
			input = reader.ReadLine();
			string[]weights = input.Split (',');
			for(i = 0; i < weights.Length; i++)
				weights[i] = weights [i].Trim();
			
			input = reader.ReadLine();
			string[] number = input.Split(',');
			for(i = 0; i < number.Length; i++)
				number[i] = number [i].Trim();
			
		}

			string studentFileName = "students_" + fileName + ".txt";
			
			var reader2 = new StreamReader (studentFileName);
			while (!reader2.EndOfStream) {
				string student = reader2.ReadLine ();
				int[] totalGrade = new int[category.Length] ;
				string [] studentData = student.Split(',');
				string studentFile = ("studentData[0]" + fileName + ".data" );
				var reader3 = new StreamReader (studentFile);

			{
			while (!reader3.EndOfStream){
				string grade = reader3.ReadLine();
				string [] gradeValue = grade.Split(',');

			// TEMPORARY line to get oriented to the file system:
			Console.WriteLine("Current directory: " + 
			                  Directory.GetCurrentDirectory());
		}
		// codeIndex chunk                                          
		/// Take the first letter code for a catagory, and 
		/// return the index of that category in categories.
		static int codeIndex(string code, string[] categories)
		{
			for (int i = 0; i < categories.Length; i++) {
				if (categories[i].Trim().StartsWith(code)) {
					return i;
				}
			}
			return -1; //required by compiler: shouldn't reach
		}
	}                                   // end codeIndex chunk
}

	}


Is This A Good Question/Topic? 0
  • +

Replies To: I am receiving a parsing error I believe I am missing a bracket

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3652
  • View blog
  • Posts: 11,421
  • Joined: 05-May 12

Re: I am receiving a parsing error I believe I am missing a bracket

Posted 14 April 2013 - 08:57 PM

On line 31 you have a closing curly brace that matches with the one on line 9. This is makes the rest of the code be statements that are not contained in a function and thereby giving your your errors.

If you are using Visual Studio, (unless you turned off the option), there are hot keys to showing you the matching braces. In VS2012, it is more overt about highlighting the matching braces.

This post has been edited by Skydiver: 14 April 2013 - 08:58 PM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1