2 Replies - 527 Views - Last Post: 21 November 2009 - 08:59 AM Rate Topic: -----

#1 itsinthetopcorner11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 21-November 09

illegal start of expression

Posted 21 November 2009 - 08:36 AM

keep getting illegal start of expression at second method what do I do?
please help!



import java.io.*;
public class project
{
public static void mainmenu ( ) throws IOException
{
int input;
int score= 0;
System.out.println(" * * * * Welcome * * * * ");
System.out.println("Please Enter The Game You Would Like To Play");
System.out.println("Press 1 for The General Knowledge Quiz");
System.out.println("Press 2 for The Number Guesser");
System.out.println("Press 3 for The Maths Quiz");

InputStreamReader read =new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(read);
input = Integer.parseInt(in.readLine());
switch(input)
{
case 1:
gkquiz( );
break;
case 2:
numguess( );
break;
case 3:
mathquiz( );
break;
default:
System.out.println("Input invalid.Please retry");
mainmenu( );
}
private static void GKquiz( )
{
System.out.println("Welcome to the General Knowledge Quiz")

Is This A Good Question/Topic? 0
  • +

Replies To: illegal start of expression

#2 erik.price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 485
  • View blog
  • Posts: 2,690
  • Joined: 18-December 08

Re: illegal start of expression

Posted 21 November 2009 - 08:58 AM

Posted Image
It's easier for us to read your code if you format it correctly.

And if you had indented correctly, you would have seen that you are missing a closing curly brace before GKquiz()
Was This Post Helpful? 1
  • +
  • -

#3 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10390
  • View blog
  • Posts: 38,455
  • Joined: 27-December 08

Re: illegal start of expression

Posted 21 November 2009 - 08:59 AM

Please :code:

It looks like the reason you are getting an error is b/c you are declaring GKquiz() inside of main. Remember, methods cannot be declared inside of other methods. Also, the println() statement w/in GKquiz() needs to end in a semi-colon as well.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1