Java Question What is wrong with code?

Java Question What is wrong with code?
So here is the deal. Here is the code.
import java.util.Scanner;

public class TwoIntegers {
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
System.out.println(“Please enter first integer”);
int x = input.nextInt();
System.out.println(“Please enter second integer”);
int y = input.nextInt();
int sum = x+y;
if (sum <= 10 && sum >= 6)
{System.out.println(sum);
}
else
if (sum < 6)
{System.out.println("Small Sum");
}
else
if (sum > 10)
{System.out.println(“Large Sum”);
}
}
}

Here is the errors compiler gives me

Compiling…
Standard Output from javac:
/tmp/1068/TwoIntegers.java:1: cannot resolve symbol
symbol : class Scanner
location: package util
import java.util.Scanner;
^
/tmp/1068/TwoIntegers.java:5: cannot resolve symbol
symbol : class Scanner
location: class TwoIntegers
Scanner input = new Scanner (System.in);
^
/tmp/1068/TwoIntegers.java:5: cannot resolve symbol
symbol : class Scanner
location: class TwoIntegers
Scanner input = new Scanner (System.in);
^
3 errors

How to fix it.

Thank you.

Best answer:

Type:
java -version

If it isn’t 1.5 or 1.6 you haven’t got java.util.Scanner

Tags: , , ,

Under Forum

1 Comment for Java Question What is wrong with code?

  • 1. You did what? RTFM!  |  November 13th, 2007 at 10:46 pm

    Sure you are using the right compiler?

Leave a Comment for Java Question What is wrong with code?

Required

Required, hidden

Trackback this post  |  Subscribe to the comments via RSS Feed


Forum