anonymous
2009-02-11 10:18:37 UTC
public class Stats {
public static int students, studentsTotal, a , max, min ;
public static double average;
public void Input(){
int grades=0;
System.out.println("This program provides statistics (such as min, max, and average)");
System.out.println("following the input of numerical data.");
System.out.println("");
Scanner keyboard = new Scanner (System.in);
System.out.println("Enter the total number of integers you'd like to compare:");
students = keyboard.nextInt();
studentsTotal = students;
System.out.println("Enter each number separately, followed by return");
max = keyboard.nextInt();
min=max; //sets initial min and max
students--;
do{
int temp = keyboard.nextInt();
if(temp>max)
max=temp;
if(temp
grades+=temp;
students--;
}while(students>0);
if(studentsTotal<=0)
average = 0;
else
average = (double)grades/studentsTotal;
}
}
I get 2 errors
frankie.udel.edu% javac Stats.java
Stats.java:20: Class Scanner not found.
Scanner keyboard = new Scanner(System.in);
^
Stats.java:20: Class Scanner not found.
Scanner keyboard = new Scanner(System.in);
Since Scanner is kind of new it does not work in unix terminal.
can any one make this code work the way why but using something other than Scanner. Im not sure if BufferReader would work
Thank you in advance