I am working on this project for my class, and I am getting an error when im trying to compile. I dont understand what the problem is. can some one help me out. The error is
"Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
symbol: class Student
location: class lab6.ReadSource
at lab6.ReadSource.main(ReadSource.java:21)"

Write a program to keep records and perform statistical analysis for a class of students. The class may have up to 40 students. There are five quizzes during the term. Each student is identified by a four-digit student ID number.
The program is to print the student scores and calculate and print the statistics for each quiz. The output is in the same order as the input; no sorting is needed. The input is to be read from a text file. The output from the program should be similar to the following -
Stud Q1 Q2 Q3 Q4 Q5
1234 78 83 87 91 86
2134 67 77 84 82 79
1852 77 89 93 87 71
High Score 78 89 93 91 86
Low Score 67 77 84 82 71
Average 73.4 83.0 88.2 86.6 78.6

Try and implement ideas learnt in class.
Use one and two-dimensional arrays only. Test your program with the following data -

Stud Qu1 Qu2 Qu3 Qu4 Qu5
1234 052 007 100 078 034
2134 090 036 090 077 030
3124 100 045 020 090 070
4532 011 017 081 032 077
5678 020 012 045 078 034
6134 034 080 055 078 045
7874 060 100 056 078 078
8026 070 010 066 078 056
9893 034 009 077 078 020
1947 045 040 088 078 055
2877 055 050 099 078 080
3189 022 070 100 078 077
4602 089 050 091 078 060
5405 011 011 000 078 010
6999 000 098 089 078 020

Some help with Lab 6
---------------------
You must apply the following concepts in Lab 6.
1. Object Theory
2. File IO
3. Wrapper Classes.

Class 1

import java.io.*;
import java.util.StringTokenizer;
public class ReadSource
{
    //Example references
    //ReadSource.java -- shows how to work with readLine and FileReader
    //How do you tokenize a String
    //How to convert a String to an Integer
    
	//int x = Integer.parseInt(String) ;

        //Putting it altogether:
        public static void main(String [] args)
	{
            /************************
             * IF STUDENTS > 40
             * PRINT "TOO MANY RECORDS"
             * AND QUIT PROGRAM
             ************************/
            Student lab6 [] = new Student[40];
            //Populate the student array
            if (lab6.length > 40)
            {
                System.out.println("Too Many Records");
            }

            lab6 = Util.readFile("Data.txt", lab6);
            Statistics statlab6 = new Statistics();
            statlab6.findlow(lab6);
            //add calls to findhigh and find average
            //Print the data and statistics
            StringTokenizer st = new StringTokenizer("this is a test");
            while (st.hasMoreTokens())
            {
                System.out.println(st.nextToken());
            }
        }
}

Class 2

import java.io.*;
public class Student
{
    private int SID;       //Student ID
    private Integer scores[] = new Integer[5];

    public int getSID() {
        return SID;
    }
    public void setSID(int SID) {
        this.SID = SID;
    }
    public Integer[] getScores() {
        return scores;
    }
    public void setScores(Integer[] scores) {
        this.scores = scores;
    }
    
    //add methods to print values of instance variables.
    public String Print()
    {
        Student [] students = new Student[5];
        for (int i = 0; i < students.length; i++)
        {
            return ("SID: " + this.SID + "Scores" + this.scores);
        }
        return ("SID: " + this.SID + "Scores" + this.scores);
    }
}

Class 3

package Lab6;
import java.io.*;
import corejava.*;
public class Util
{
    public static Student [] readFile(String filename, Student [] stu)throws Exception
    {
    /*  - Reads the file and builds student array.
	- Open the file using FileReader Object.
	- In a loop read a line using readLine method.
	- Tokenize each line using StringTokenizer Object
	- Each token is converted from String to Integer using parseInt method
	- Value is then saved in the right property of Student Object.
    */
        String x;
        FileReader fr = new FileReader("Data.txt");
        BufferedReader br = new BufferedReader(fr);
        while ((x = br.readLine())!= null)
        {
            System.out.println(x);
        }
        fr.close();
        return stu;
    }
    Student a1[][] = new Student [40][6];  //array of object references
    //if numofrows > 40 exit with an error message else compute statistics
    /* if number of rows < 40
     *     a1[] = new Student (...........);
     *     where i < 40
     */
    public static void read()
    {

    }
}

Edited 6 Years Ago by yasaswyg: n/a

good, it should give that error. You've just proven that your compiler works.
It can't find the class because the class isn't in the same package and you failed to import it.
You stupidly didn't put the class in a package so it's of course quite impossible to import it, but that's something you can easily rectify.

Comments
ignorance and 'oopsyness' != stupidity

good, it should give that error. You've just proven that your compiler works.
It can't find the class because the class isn't in the same package and you failed to import it.
You stupidly didn't put the class in a package so it's of course quite impossible to import it, but that's something you can easily rectify.

Damn man you dont have to be so harsh. I did put it in the same package, but its still giving me the same error.

Are you having all the classes in the same folder?

Yes I have all these classes in the same folder. I put the "Data.txt" in the same folder too but it doesnt recognize it

Ur Util class is in package "Lab6" .... but Student and ReadSource are not in that same package...........

May be that could be the problem .......

Thanks for focusing too much on the packages instead of the actual problems. thank you very much

Wat r u trying to tell??? I thought that might be the reason for the Problem.... Its not the problem ah???? u got the solution or not????

no that was not the problem anymore. I am done with this project tho. thanks i guess.
im sorry i was confusing you guys with some other website.

This article has been dead for over six months. Start a new discussion instead.