Jump to content

Featured Replies

Posted

well i am having a bit of trouble with this script.. im new to this so its a simple code

 

import java.util.*;

public class UserInput
{
public static void main(String[] args)
{
	int intInput;
	String stringInput;

	Scanner input = new Scanner(System.in);

	System.out.print("Whats Your Name? ");
	stringInput = input.nextLine();

	System.out.print("Whats Your age? ");
	stringInput = input.nextInt();

	input.close();

	System.out.print("Hello " + stringInput + "You are " + intInput + " Years old");

 	}
}

 

and here is my errors while i compile

 

C:\Documents and Settings\Ryan Swango\Desktop\My Applets\UserInput.java:10: cannot resolve symbol

symbol : class Scanner

location: class UserInput

Scanner input = new Scanner(System.in);

^

C:\Documents and Settings\Ryan Swango\Desktop\My Applets\UserInput.java:10: cannot resolve symbol

symbol : class Scanner

location: class UserInput

Scanner input = new Scanner(System.in);

^

2 errors

 

Tool completed with exit code 1

 

 

HELP PlEASE!!

I know NOTHING Java, but are you sure theres a type called Scanner (with that case, I am pretty sure Java is case sensitive).

You need to use JDK 1.5 to compile it.

Also there's a small error in your code:

 

stringInput = input.nextInt();

 

Needs to be:

 

intInput = input.nextInt();

Guest
This topic is now closed to further replies.