Hello great java minds. Could you please tell me why I get "illegal start of expression" errors for the following headers? Thanks for your wisdom!!

Lines generating this error:

public static String getName()

--and--

public static void displayResults()

Here is my first class (that includes this code):

import java.io.*;
import java.util.*;

public class ProductSurvey 
{
	public static void main(String [] args)
	{		
	
		ProductData myData = new ProdcutData();
		
		String name = getName();
		openFile();
		myData.setName(name);
		myData.dataRetrieve(name);
		myData.updateAverages(rating1totalLow, rating2totalLow, rating3totalLow, rating1totalMed, rating2totalMed, rating3totalMed, rating1totalHigh, rating2totalHigh, rating3totalHigh, inc1total, inc2total, inc3total);
		mydata.setRating2ave1lower3(rating2lower1than3, lower1than3Total);
		displayResults();
	
		
		public static String getName()
		{
			System.out.println("Please enter income and product info file name:  ");
			Scanner keyboard = new Scanner(System.in);
			String name = keyboard.next();
			return name;
		}
		
		public static void openFile();
		{
	
			File fileObject = new File(name);
			while ((! fileObject.exists()) || ( ! fileObject.canRead()))
		
			{
				if( ! fileObject.exists())
				{
					System.out.println("No such file");
				}
				else
				{
					System.out.println("That file is not readable.");
				}
			
					System.out.println("Enter file name again:");
					name = keyboard.next();
					fileObject = new File(name);				
			}		
				
		}
		
		
		public static void displayResults()
		{
		
			System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
			System.out.println("*Average (rounded) product ratings, by income bracket, are as follows: ");
			System.out.println(myData.toString());
			System.out.print("\n*Total number of persons in Income Bracket $50000-$74999 ");
			System.out.print("that rated all three products with a score of 5 ");
			System.out.println("or higher: " + myData.getHighRaters());
			System.out.print("\n*Average (rounded) rating for Product 2 by ");
			System.out.println("persons who rated Product 1 lower than Product 3: " + myData.rating2ave1lower3);
			
		}		
		
	}
	
}

Here is the backup class (just for your reference):

import java.util.*;
import java.io.*;

class ProductData 
{
		private String name;
		private int lineCount;
		private double inc1total;
		private double inc2total;
		private double inc3total;
		private int rating1totalLow;
		private int rating2totalLow;
		private int rating3totalLow;
		private int rating1totalMed;
		private int rating2totalMed;
		private int rating3totalMed;
		private int rating1totalHigh;
		private int rating2totalHigh;
		private int rating3totalHigh;
		private int highRaters;
		private double lower1than3Total;
		private int rating2lower1than3;
		private long rating2ave1lower3;
		private long rating1averageLow; 
		private long rating2averageLow; 
		private long rating3averageLow; 
		private long rating1averageMed; 
		private long rating2averageMed; 
		private long rating3averageMed; 
		private long rating1averageHigh; 
		private long rating2averageHigh; 
		private long rating3averageHigh; 
		
		public ProductData()
		{
			name = null;
			lineCount = 0;
			inc1total = 0;
			inc2total = 0;
			inc3total = 0;
			rating1totalLow = 0;
			rating2totalLow = 0;
			rating3totalLow = 0;
			rating1totalMed = 0;
			rating2totalMed = 0;
			rating3totalMed = 0;
			rating1totalHigh = 0;
			rating2totalHigh = 0;
			rating3totalHigh = 0;
			highRaters = 0;
			lower1than3Total= 0;
			rating2lower1than3 = 0;
			rating1averageLow = 0;
			rating2averageLow = 0;
			rating3averageLow = 0;
			rating1averageMed = 0;
			rating2averageMed = 0;
			rating3averageMed = 0;
			rating1averageHigh = 0;
			rating2averageHigh = 0;
			rating3averageHigh = 0;	
		}
		
		public void setName(String newName)
		{
			String name = newName;
		}
		
		public void dataRetrieve(String name)
		{
			try
			{
				BufferedReader inputStream = new BufferedReader(new FileReader(name));
			
				String trash = "No trash yet";
				while ((trash = inputStream.readLine()) !=null)
				{
					StringTokenizer st = new StringTokenizer(trash);
					int income = Integer.parseInt(st.nextToken());
					int rating1 = Integer.parseInt(st.nextToken());
					int rating2 = Integer.parseInt(st.nextToken());
					int rating3 = Integer.parseInt(st.nextToken());
					
					if(rating1<rating3)
					{
						lower1than3Total++;
						rating2lower1than3 = rating2lower1than3 + rating2;
					}
					
					if(income<50000)
					{
						rating1totalLow = rating1totalLow + rating1;
						rating2totalLow = rating2totalLow + rating2;
						rating3totalLow = rating3totalLow + rating3;
						inc1total++;
					
					}
					
					else if(income<75000)
					{
						rating1totalMed = rating1totalMed + rating1;
						rating2totalMed = rating2totalMed + rating2;
						rating3totalMed = rating3totalMed + rating3;
						inc2total++;
						if((rating1>=5) && (rating2>=5) && (rating3>=5))
						{
							highRaters++;
						}
						
					}
					
					else if(income<100000)
					{
						rating1totalHigh = rating1totalHigh + rating1;
						rating2totalHigh = rating2totalHigh + rating2;
						rating3totalHigh = rating3totalHigh + rating3;
						inc3total++;
					}
					
					lineCount++;
					
				}
				
				inputStream.close();
			}
			catch(IOException e)
			{
				System.out.println("Problem reading from file.");
			}		
		}
		
		public void updateAverages(int rating1totalLow, int rating2totalLow, int rating3totalLow, int rating1totalMed, int rating2totalMed, int rating3totalMed, int rating1totalHigh, int rating2totalHigh, int rating3totalHigh, long inc1total, long inc2total, long inc3total)
		{
			rating1averageLow = Math.round(rating1totalLow/inc1total);
			rating2averageLow = Math.round(rating2totalLow/inc1total);
			rating3averageLow = Math.round(rating3totalLow/inc2total);
			rating1averageMed = Math.round(rating1totalMed/inc2total);
			rating2averageMed = Math.round(rating2totalMed/inc2total);
			rating3averageMed = Math.round(rating3totalMed/inc2total);
			rating1averageHigh = Math.round(rating1totalHigh/inc3total);
			rating2averageHigh = Math.round(rating2totalHigh/inc3total);
			rating3averageHigh = Math.round(rating3totalHigh/inc3total);
		}
	
		public long setRating2ave1lower3(int rating2lower1than3, double lower1than3Total)
		{
			long rating2ave1lower3 = (rating2lower1than3/lower1than3Total);
			return rating2ave1lower3;
		}
		
		public String toString()
		{
			return ("\nIncome level $26000-$49999:" + "\n" + "-Product 1: "
				 + rating1AverageLow + "-Product 2: " + rating2AverageLow
				 + "-Product 3: " + rating3AverageLow + "\n" + "\n" + "Income level $50000-$74999:" + "\n" + "-Product 1: "
				 + rating1AverageMed + "-Product 2: " + rating2AverageMed
				 + "-Product 3: " + rating3AverageMed + "\n" + "\n" + "Income level $75000-$100000:" + "\n" + "-Product 1: "
				 + rating1AverageHigh + "-Product 2: " + rating2AverageHigh
				 + "-Product 3: " + rating3AverageHigh);
		}
		
		public int getHighRaters()
		{
			return highRaters;
		}
	
	
}

Its because you're defining methods inside of another method.

remove the public static String getName(), public static void openFile(); (btw, you need to remove the ; here), and public static void displayResults() from the public static void main(String[] args) method.

So your code should look more like...

public class TestClass
{
  public static void main(String[] args)
  {
  }

  public static String getName()
  {
  }

  public static void openFile()
  {
  }

  public static void displayResults()
  {
  }
}

hello buddy, you are trying to write method within main method, put your method ou of your main method in same class and try out, i hope it'll help..
me too had same prblm solved with this solution

It looks like this post has been solved , why is still showing unsolved ???

because the OP hasn't marked it as "solved" yet.

yes, u need to mark it as solved if the if the u are satisfied with the solution given by any of the users

or you should have watched at the date, and realised this thread is about 5 years old.
there wasn't really a point in reviving it, since the answer to the OP's problem was given in 2006. if he/she didn't mark it as solved back then chances are pretty big it won't happen now.

if an admin reads this, I think it's pretty save to close this thread.

in fact OP most likely doesn't even remember ever visiting this site, if it even remembers the site exists.

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.