5 Replies - 778 Views - Last Post: 11 May 2011 - 08:46 PM Rate Topic: -----

#1 duckymeboy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 11-May 11

Class, Interface, or Enum Expected

Posted 11 May 2011 - 08:14 PM

Hi, I'm a new Java programmer and am making a questionnaire thing for practice and I have this error: poopoo.java:2: class, interface, or enum expected
importjava.util.Scanner;
^
1 error.
I don't know what it means; I checked where it's talking about and couldn't fix it... If you will please help me put.
Here is my program:
importjava.util.Scanner;
public class Test { 
//Making a first questionaire!
	public static void main (Sting[] args){
		Scanner sc=new Scanner(System.in);
		
		System.out.println("What is the square root of everything?:");
		int answer = sc.nextInt();
		
		if(answer == 226)
			System.out.println("You are a wise one...");
		else
			System.out.println("You are an idiot!!!");

	}
}


This post has been edited by macosxnerd101: 11 May 2011 - 08:18 PM
Reason for edit:: Please use code tags and a descriptive title


Is This A Good Question/Topic? 0
  • +

Replies To: Class, Interface, or Enum Expected

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10183
  • View blog
  • Posts: 37,596
  • Joined: 27-December 08

Re: Class, Interface, or Enum Expected

Posted 11 May 2011 - 08:19 PM

You need a space between the words import and java for it to be read as a valid statement.
Was This Post Helpful? 0
  • +
  • -

#3 duckymeboy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 11-May 11

Re: Class, Interface, or Enum Expected

Posted 11 May 2011 - 08:38 PM

Thanks, bu ti tried that once and it didn't change anything... Is there anything?
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10183
  • View blog
  • Posts: 37,596
  • Joined: 27-December 08

Re: Class, Interface, or Enum Expected

Posted 11 May 2011 - 08:40 PM

Post your revised code and error message(s).
Was This Post Helpful? 0
  • +
  • -

#5 duckymeboy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 11-May 11

Re: Class, Interface, or Enum Expected

Posted 11 May 2011 - 08:44 PM

It's all good now I fixed it thanks for your help... i spelled String as Sting and i didn't know you had to name your program the same as the class (that fixed it)

Revised:
import java.util.Scanner;
public class poopoo {
//Making a first questionaire!
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		System.out.println("What is the square root of everything?:");
		int answer = sc.nextInt();
		
		if(answer == 226)
			System.out.println("You are a wise one...");
		else
			System.out.println("You are an idiot!!!");

	}
}



Edited by macosxnerd101: Please, :code:.
Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10183
  • View blog
  • Posts: 37,596
  • Joined: 27-December 08

Re: Class, Interface, or Enum Expected

Posted 11 May 2011 - 08:46 PM

Glad I could help! :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1