java error……….???
java error……….???
This my code but i always keep getting a ‘cannot resolve symbol’ error on my import java.util.Scanner; anyone know why?
import java.util.Scanner;
public class Population{
public static void main(String [] args){
Scanner reader = new Scanner(System.in);
int initialPop;
double growthRate;
int hours;
double popGrowth;
int totalPop = 0;
int totalhours;
System.out.print(“Enter the initial number of organisms:”);
initialPop = reader.nextInt();
System.out.print(“Enter the rate growth:”);
growthRate = reader.nextDouble();
System.out.print(“Enter the number of hours population grows:”);
hours = reader.nextInt();
System.out.println(“Enter the number of hours the growth rate achieves:”);
totalhours = reader.nextInt();
System.out.println(“At this rate the population will be:”);
for(int hourscalc = 0;hours>0; hourscalc+=2){
totalPop =(int)(initialPop * growthRate);
System.out.println(totalPop);
}
}
}
i am also geting the same error on Scanner reader, do i have to make a Scanner class oath, and if so how do i make it?
Best answer:
when you compile make sure you use javac and also make sure you set the class path to the compiler
Under Forum

1 Comment for java error……….???
1. Hari | September 30th, 2007 at 11:03 am
If your Java is not version 1.5 or above, Scanner class is not provided.
Try
java -version[Enter]
from console to get the version.
alternatively you can use
import java.io.*;
try{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
}
catch (IOException e){
e.printStackTrace();
}
String line = br.readLine();
int n = Integer.parseInt(line); // if you want an integer from a digit string
Leave a Comment for java error……….???
You must be logged in to post a comment.
Trackback this post | Subscribe to the comments via RSS Feed