Jave Error: import java.util.Scanner;

Posted on 2009-04-01
Last Modified: 2012-05-06
I am taking a college course in Jave and I am very new at this.  I have been trying to compile some code and I keep getting this error: cannot resolve symbol
symbol  : class Scanner
location: package util
import java.util.Scanner;
                 ^ cannot resolve symbol
symbol  : class Scanner
location: class AverageGrades
       Scanner input = new Scanner ( );
       ^ cannot resolve symbol
symbol  : class Scanner
location: class AverageGrades
       Scanner input = new Scanner ( );
3 errors

import java.util.Scanner;

import javax.swing.*;


public class AverageGrades {

   int count;

   public double enterGrades () {


       Scanner input = new Scanner ( );


       double grade = 0;

       double sum = 0;

       int gradeCounter = 0;


     // Enter grades

     System.out.println( "Enter grades (Grade of 0 causes average calculation: ");

     grade = input.nextDouble();


     //calculate the total of all grades entered


     for (gradeCounter = 0; grade != 0; gradeCounter++ ){

        sum = sum + grade;

        System.out.println( "Enter grades (Grade of 0 causes average calculation: ");

        grade = input.nextDouble();


     count = gradeCounter;

     return sum;



   public double aveGrades (double sum ) {

   //calculate the average


     double average = 0;     

     average = (double) sum / count;

     System.out.println( "The grade average is " + average );

     return average;



     public static void main(String[] args){

     AverageGrades aGrades = new AverageGrades();

     double sum = aGrades.enterGrades();

     System.out.println("Sum : "+sum);

     double average = aGrades.aveGrades(sum);

     System.out.println("Count : "+aGrades.count);

     System.out.println("Average : "+average);

     } // end Main

} // end Class

Open in new window

Question by:JudyTillman
LVL 92

Expert Comment

Comment Utility
Scanner was only added in 1.5, make sure you have a 1.5+ version of jdk
LVL 26

Accepted Solution

ksivananth earned 125 total points
Comment Utility
even if you have installed multiple version of Java and the older version is set in path  could lead problem.

check java version by executing java -version

if it prints older( < 1.5 ) version of JDK, modify the path variable to refer the latest

Author Closing Comment

Comment Utility
With me being new to Java and programming it was difficult to find the right JDK pack.  However on my 3rd download of items from    I finally found the right JDK pack.  Thanks you.

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now