Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Jave Error: import java.util.Scanner;

Posted on 2009-04-01
3
1,139 Views
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:

AverageGrades.java:1: cannot resolve symbol
symbol  : class Scanner
location: package util
import java.util.Scanner;
                 ^
AverageGrades.java:8: cannot resolve symbol
symbol  : class Scanner
location: class AverageGrades
       Scanner input = new Scanner ( System.in );
       ^
AverageGrades.java:8: cannot resolve symbol
symbol  : class Scanner
location: class AverageGrades
       Scanner input = new Scanner ( System.in );
                           ^
3 errors

import java.util.Scanner;
import javax.swing.*;
 
public class AverageGrades {
   int count;
   public double enterGrades () {
       
       Scanner input = new Scanner ( System.in );
   
       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

0
Comment
Question by:JudyTillman
3 Comments
 
LVL 92

Expert Comment

by:objects
ID: 24046025
Scanner was only added in 1.5, make sure you have a 1.5+ version of jdk
0
 
LVL 26

Accepted Solution

by:
ksivananth earned 125 total points
ID: 24047136
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
0
 

Author Closing Comment

by:JudyTillman
ID: 31565623
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 http://java.sun.com/javase/downloads/index.jsp    I finally found the right JDK pack.  Thanks you.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
fibonacci ten numbers 4 45
Windows 10 IE Certificate Issue 10 51
login form jsp example 2 35
java example issue 3 20
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to implement Singleton Design Pattern in Java.

809 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