I have been working with my final project for about 3 weeks now and its due by 10am tuesday. Currently I am receiveing cannot find symbol errors. I know this is something simple. Please help.

INSTRUCTIONS
Create a program to enter grades and calculate averages and letter grades.
1. Need a class which will contain:
a. Student Name
b. Student Grades (an array of 3 grades)
c. A constructor that clears the student data (use -1 for unset grades)
d. Accessors (get functions) for each of the above, average, and letter grade
e. Mutators (set functions) for items a, b, c
f. Note that the accessor and mutator for Student grades has to have an argument for the grade index.
2. Need another class which will contain:
a. An Array of Students (1 above)
b. A count of number of students in use
c. Constructor that reads data from a text file and sets up the students
3. You need to create a graphical user interface that allows you to:
a. Read data from file
b. Add new students
c. Process existing students
d. Add test grades
e. Based on a radio button setting display either the average or the letter grade
f. Save modified data to file
4. A possible graphical look is as follows:

5. Add comments and use proper indentation.
NOTE: You need actionCommand to handle saving a file and you cannot modify actionCommand with a “throws IOException” clause. The way to solve this is as follows:
Assuming that you have a method called saveData that saves the data, change its call as follows:
try
{ saveData();
} catch (IOException x)
{
}
The function saveData, your function to load data, and the constructor will need a “throws IOException” clause.
Additional Information:
• An accessor is needed to save the test grades, which should always be numbers.
• I would like that system to accept a student with no grades, then later add one or more grades, and when all grades are entered, calculate the final average or grade.
• The way to handle changes in data using a text file is:
o Open the data file for reading
o load all the data into an array of students from the file,
o Close the file
o Make all modifications to the data in the array of students.
o When saving, open the datafile for writing
o Loop through the students and save the data to the datafile.
o Close the data file.
This project is a challenge. Do the best you can and I will grade it accordingly.
Basically, I will award points for
1. Creating a user interface that meets my criteria (screen form)
2. Creating a Student class that can perform the tasks requested
3. Creating an array of Student and loading it
4. Modifying the data in that array and moving between students
5. Handling the Calc button and using the Radio Buttons to determine what result to get and display.
6. Saving data in the datafile.
7. Items 1, 2, and 5 are worth 60 points. Items 3, 4, and 6 are worth 20 points and using proper indentation and comments is worth 20 points.
8. Note that submitting a program that does not compile is an automatic deduction of 20 points.
If you have any questions, please contact me as soon as possible.

import javax.swing.*; //needed for swing classes 
   import java.awt.event.*; // needed for the action listener 
   import java.awt.*;//needed for the boader layout class 
   import java.io.*; //need for the file and IOException 
   import java.util.Scanner;// needed for the scanner class 
   import java.util.List;  // needed for the  arraylist 
   import java.util.Arrays;  //needed for the arraylict class 
  
    /** 
  
    */ 
  
  
    public class project2 extends JFrame  
   { 
  
      public gradeTypePabel gradeType; //to reference the the grade Type Pabel with the radio buttons 
      public namePanel name; // to reference the name panel with the name text field 
      public testPanel test;// to reference the test panel with the 3 test grade fields 
      public resultPanel result;// to reference the result panel with the result text field 
      private JPanel panel; // to reference the a  panel 
      private JButton calcButton; // creats the Button named calcButton 
      private JButton prevButton; // creats the Button named prevButton 
      private JButton nextButton; // creats the Button named nextButton 
      private JButton saveButton; // creats the Button named saveButton 
      private JPanel buttonPanel; // to  reference the panel where all the buttons go 
      public openFile open;// to reference the open file class 
      public int masterIndex = -1; // this controls all the of the indexes of all 4 arrays 
  
       // constructs the window 
       public project2() 
      { 
         // sets the title 
         setTitle("Grading Program"); 
         // set what happens when the exit button is clicked 
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
         // sets the border layout 
         setLayout(new BorderLayout()); 
         //calls the resultPanel class and names it result 
         result = new resultPanel(); 
         //calls the gradeTypePanel and names it gradeType 
         gradeType = new gradeTypePabel(); 
         //calls the namePanel and names it name 
         name = new namePanel(); 
         //calls the testPanel and names it test 
         test = new testPanel(); 
  
          //builds the button panel 
         buildButtonPanel(); 
  
          //adds all of the panels to the north, south, east, west, and center panels 
         add(name, BorderLayout.NORTH);   
         add(gradeType, BorderLayout.WEST); 
         add(test, BorderLayout.CENTER); 
         add(buttonPanel, BorderLayout.EAST); 
         add(result, BorderLayout.SOUTH); 
  
          // packs all the panels togather 
         pack(); 
  
          //makes the window visable 
         setVisible(true); 
      } 
  
      //builds the panel for the buttons 
       private void buildButtonPanel() 
      { 
  
         buttonPanel = new JPanel(); 
  
  
         prevButton = new JButton("Prev");// adds the text prev to the prevButton 
         calcButton = new JButton("Calc Grade");// adds the text Calc Grade to the calcButton 
         nextButton = new JButton("Next");// adds the text Next to the nextButton  
         saveButton = new JButton("Save");// adds the text Save to the saveButton 
  
  
         calcButton.addActionListener(new CalcButtonListener());// calls the  ActionListener for the calcButton 
         prevButton.addActionListener(new PrevButtonListener());// calls the  ActionListener for the prevButto 
         nextButton.addActionListener(new NextButtonListener());// calls the  ActionListener for the nextButton 
         saveButton.addActionListener(new SaveButtonListener());// calls the  ActionListener for the addButton 
  
  
         buttonPanel.add(prevButton);// adds the prevButton to the panel 
         buttonPanel.add(saveButton);// adds the saveButton to the panel 
         buttonPanel.add(nextButton);// adds the nextButton to the panel 
         buttonPanel.add(calcButton);// adds the calcButton to the panel 
  
  
      } 
       //creats actionlistener for the Calc Grade button 
       private class CalcButtonListener implements ActionListener 
      { 
          // executes when the button is clickd  
          public void actionPerformed(ActionEvent e) 
         { 
           //if masterIndex = -1 then you are not at index 0 of the arrays so you cant calculate 
            if(masterIndex != -1) 
            { 
               String nameText;// to save the text in the name text field 
               nameText = name.txtname.getText();//gets the text form name text field 
               String grade1;// to save the text in the test1 text field 
               grade1 = test.test1TextFild.getText();//gets the text form test1 text field 
               String grade2;// to save the text in the test2 text field 
               grade2 = test.test2TextFild.getText();//gets the text form test2 text field 
               String grade3;// to save the text in the test3 text field 
               grade3 = test.test3TextFild.getText();//gets the text form test3 text field 
  
               //if the text in all 3 text field are  <= 100 calculate 
               if(Double.parseDouble(grade1) <= 100 && Double.parseDouble(grade2) <= 100 && Double.parseDouble(grade3) <= 100) 
               { 
                  //convert and add all 3 grades together 
                  double totalGrade = Double.parseDouble(grade1) + Double.parseDouble(grade2) + Double.parseDouble(grade3);  
                   //get the the avarage 
                  double NumberGrade = (totalGrade / 300) * 100; 
                   //to hold the letter grade 
                  String letterGrade; 
                  //if the alphabetical radio button is Selected get the letter grade 
                  if(gradeType.alphabetical.isSelected()) 
  
                  { 
  
  
                     if(NumberGrade >= 90) 
                     { 
                        //sets letter grade to A 
                        letterGrade = "A"; 
                         //display the result in the result text field 
                        result.textResult.setText(letterGrade); 
  
                     } 
                     else if(NumberGrade >= 80) 
                     { 
                        //sets letter grade to B 
                        letterGrade = "B"; 
                         //display the result in the result text field 
                        result.textResult.setText(letterGrade); 
                     } 
                     else if(NumberGrade >= 70) 
                     { 
                        //sets letter grade to C 
                        letterGrade = "C"; 
                         //display the result in the result text field 
                        result.textResult.setText(letterGrade); 
                     } 
                     else if(NumberGrade >= 60) 
                     { 
                        //sets letter grade to D 
                        letterGrade = "D"; 
                         //display the result in the result text field 
                        result.textResult.setText(letterGrade); 
                     } 
                     else if(NumberGrade < 60) 
                     { 
                        //sets letter grade to F 
                        letterGrade = "F"; 
                         //display the result in the result text field 
                        result.textResult.setText(letterGrade); 
                     } 
  
  
                  } 
                   //if numerical is Selected get the number grade 
                  if(gradeType.numerical.isSelected()) 
                  { 
                     //display the result in the result text field 
                     result.textResult.setText(Double.toString(NumberGrade)); 
                  } 
               } 
               else 
               { 
                  //displays error message when all grades are not <= 100 
                  JOptionPane.showMessageDialog(null, "All Grades must be less than or equal to (100)"); 
               } 
            } 
            else 
            { 
                //shows error message when masterIndex == -1 
               JOptionPane.showMessageDialog(null, "Please click (Next) first"); 
            } 
  
         }                                         
      } 
      //creats actionlistener for the Calc prev button 
       private class PrevButtonListener implements ActionListener 
      { 
          // executes when the button is clickd gets the input and calcilates it 
          public void actionPerformed(ActionEvent e) 
         { 
            //if masterIndex is > 0  
            if(masterIndex > 0) 
            {  
               //decrament masterIndex by 1 
               masterIndex--; 
  
               String[] nameList;//to store the array 
               String[] test1;//to store the array 
               String[] test2;//to store the array 
               String[] test3;//to store the array 
  
  
               try  
               { 
  
                  nameList = open.getArrayName();//get the nameList array from the class 
                  test1 = open.getArrayTest1();//get the test1 array from the class 
                  test2 = open.getArrayTest2();//get the test2 array from the class 
                  test3 = open.getArrayTest3();//get the test3 array from the class 
                  name.txtname.setText(nameList[masterIndex]);//populate the txtname text field with the array 
                  test.test1TextFild.setText(test1[masterIndex]);//populate the test1 text field with the array 
                  test.test2TextFild.setText(test2[masterIndex]);//populate the test2 text field with the array 
                  test.test3TextFild.setText(test3[masterIndex]);//populate the test3 text field with the array 
  
               }  
                   catch (IOException x) 
                  {  
                     //displays an error message 
                     System.out.println("Error"); 
                  }  
            } 
  
            else 
            { 
               JOptionPane.showMessageDialog(null, "There are no previous students"); 
            } 
  
         }                                 
      } 
      //creats actionlistener for the next button 
       private class NextButtonListener implements ActionListener 
      { 
          // executes when the button is clickd  
          public void actionPerformed(ActionEvent e) 
         { 
            //incrament masterIndex by 1 
            masterIndex++; 
  
            String[] nameList;//to store the array 
            String[] test1;//to store the array 
            String[] test2;//to store the array 
            String[] test3;//to store the array 
  
  
            try  
            { 
  
               nameList = open.getArrayName();//get the nameList array from the class 
               test1 = open.getArrayTest1();//get the test1 array from the class 
               test2 = open.getArrayTest2();//get the test2 array from the class 
               test3 = open.getArrayTest3();//get the test3 array from the class 
               name.txtname.setText(nameList[masterIndex]);//populate the txtname text field with the array 
               test.test1TextFild.setText(test1[masterIndex]);//populate the test1 text field with the array 
               test.test2TextFild.setText(test2[masterIndex]);//populate the test2 text field with the array 
               test.test3TextFild.setText(test3[masterIndex]);//populate the test3 text field with the array 
  
  
            }  
                catch (IOException x) 
               {  
                   //displays an error message 
                  System.out.println("Error"); 
               }  
         } 
  
      } 
      //creats actionlistener for the save button 
       private class SaveButtonListener implements ActionListener 
      { 
          // executes when the button is clickd  
          public void actionPerformed(ActionEvent e) 
         { 
             //if masterIndex = -1 then you are not at index 0 of the arrays so you cant calculate 
            if(masterIndex != -1) 
            { 
  
               try  
               { 
  
                  String[] nameList;//to store the array 
                  String[] test1;//to store the array 
                  String[] test2;//to store the array 
                  String[] test3;//to store the array 
  
                  nameList = open.getArrayName();//get the nameList array from the class 
                  test1 = open.getArrayTest1();//get the test1 array from the class 
                  test2 = open.getArrayTest2();//get the test2 array from the class 
                  test3 = open.getArrayTest3();//get the test3 array from the class 
  
                  String saveName;// to save the text in the name text field 
                  saveName = name.txtname.getText();//gets the text form name text field 
                  String saveGrade1;// to save the text in the test1 text field 
                  saveGrade1 = test.test1TextFild.getText();//gets the text form test1 text field 
                  String saveGrade2;// to save the text in the test2 text field 
                  saveGrade2 = test.test2TextFild.getText();//gets the text form test2 text field 
                  String saveGrade3;// to save the text in the test3 text field 
                  saveGrade3 = test.test3TextFild.getText();//gets the text form test3 text field 
  
                  List<String> name1List = Arrays.asList(nameList); //treats the array as an arrayList  
                  List<String> test1List = Arrays.asList(test1);//treats the array as an arrayList 
                  List<String> test2List = Arrays.asList(test2);//treats the array as an arrayList 
                  List<String> test3List = Arrays.asList(test3);//treats the array as an arrayList 
  
                  name1List.set(masterIndex, saveName);//changes of sets the value at the masterIndex to saveName 
                  test1List.set(masterIndex, saveGrade1);//changes of sets the value at the masterIndex to saveGrade1 
                  test2List.set(masterIndex, saveGrade2);//changes of sets the value at the masterIndex to saveGrade2 
                  test3List.set(masterIndex, saveGrade3);//changes of sets the value at the masterIndex to saveGrade3 
  
               //opens the file for writing 
                  PrintWriter outputFile = new PrintWriter("name.txt"); 
               //writes the array to a text file 
                  for(int index = 0; index < nameList.length; index++) 
                  { 
                     outputFile.println(nameList[index]); 
                  } 
               //closes the file     
                  outputFile.close(); 
  
               //opens the file for writing 
                  PrintWriter outputFile1 = new PrintWriter("grade1.txt"); 
               //writes the array to a text file 
                  for(int index1 = 0; index1 < test1.length; index1++) 
                  { 
                     outputFile1.println(test1[index1]); 
                  } 
               //closes the file 
                  outputFile1.close(); 
  
               //opens the file for writing 
                  PrintWriter outputFile2 = new PrintWriter("grade2.txt"); 
               //writes the array to a text file 
                  for(int index2 = 0; index2 < test2.length; index2++) 
                  { 
                     outputFile2.println(test2[index2]); 
                  } 
               //closes the file 
                  outputFile2.close(); 
  
               //opens the file for writing 
                  PrintWriter outputFile3 = new PrintWriter("grade3.txt"); 
               //writes the array to a text file 
                  for(int index3 = 0; index3 < test3.length; index3++) 
                  { 
                     outputFile3.println(test3[index3]); 
                  } 
               //closes the file 
                  outputFile3.close(); 
  
  
               }   
                   catch (IOException x) 
                  {  
                  //displays an error message 
                     System.out.println("Error!"); 
                  }   
            } 
            else 
            { 
                //shows error message when masterIndex == -1 
               JOptionPane.showMessageDialog(null, "Please click (Next) first"); 
  
            }       
         }                                         
      } 
  
       public static void main(String[] a) 
      { 
         // calls the project2 class 
         new project2(); 
  
      } 
   }

Recommended Answers

All 16 Replies

You did not difine the following classes:
gradeTypePabel,namePanelname, testPanel panel , and resultPanel

I am receiveing cannot find symbol errors

When you get errors, please copy the full text and paste them here.

When you get errors, please copy the full text and paste them here.

That will be impossible since all catch statements are simple system calls System.out.println("Error"); .

@blknmld69 replace all System.out.println("Error"); with printStackTrace(x); (x is the exception object treated by catch block)

commented: Incredibly good suggestion :) +8

When you get errors, please copy the full text and paste them here.

ERRORS:

project2.java:17: cannot find symbol
symbol : class gradeTypePabel
location: class project2
public gradeTypePabel gradeType; //to reference the the grade Type Pabel with the radio buttons
^
project2.java:18: cannot find symbol
symbol : class namePanel
location: class project2
public namePanel name; // to reference the name panel with the name text field
^
project2.java:19: cannot find symbol
symbol : class testPanel
location: class project2
public testPanel test;// to reference the test panel with the 3 test grade fields
^
project2.java:20: cannot find symbol
symbol : class resultPanel
location: class project2
public resultPanel result;// to reference the result panel with the result text field
^
project2.java:27: cannot find symbol
symbol : class openFile
location: class project2
public openFile open;// to reference the open file class
^
project2.java:40: cannot find symbol
symbol : class resultPanel
location: class project2
result = new resultPanel();
^
project2.java:42: cannot find symbol
symbol : class gradeTypePabel
location: class project2
gradeType = new gradeTypePabel();
^
project2.java:44: cannot find symbol
symbol : class namePanel
location: class project2
name = new namePanel();
^
project2.java:46: cannot find symbol
symbol : class testPanel
location: class project2
test = new testPanel();
^
project2.java:218: cannot find symbol
symbol : method printStackTrace(java.io.IOException)
location: class project2.PrevButtonListener
printStackTrace(x);
^
10 errors

cannot find symbol
symbol : class gradeTypePabel

tong1 has pointed out that your code is missing definitions for most of the errors you posted here.

Where are the class definitions for all those classes?

cannot find symbol
symbol : method printStackTrace(java.io.IOException)

For this one, you need to read the API doc for that method. You have coded it incorrectly. It doesn't take an arg. And what class is it a method of? Not the current one.

You did not difine the following classes:
gradeTypePabel,namePanelname, testPanel panel , and resultPanel

Where would i define these?

Either add them to the current source file or create new source file(s) to hold them.

ok that didnt work. Will post a new thread for help!

that didnt work

Please copy the full text of the error messages and paste them here

Please copy the full text of the error messages and paste them here

Sorry that was the new program that I started a few hours ago.

Here are the errors:

----jGRASP exec: javac -g project2.java

project2.java:17: cannot find symbol
symbol : class gradeTypeLabel
location: class project2
public gradeTypeLabel gradeType; // to reference the the grade Type Label with the radio buttons
^
project2.java:18: cannot find symbol
symbol : class namePanel
location: class project2
public namePanel name; // to reference the name panel with the name text field
^
project2.java:19: cannot find symbol
symbol : class testPanel
location: class project2
public testPanel test; // to reference the test panel with the 3 test grade fields
^
project2.java:20: cannot find symbol
symbol : class resultPanel
location: class project2
public resultPanel result; // to reference the result panel with the result text field
^
project2.java:27: cannot find symbol
symbol : class openFile
location: class project2
public openFile open; // to reference the open file class
^
project2.java:40: cannot find symbol
symbol : class resultPanel
location: class project2
result = new resultPanel();
^
project2.java:42: cannot find symbol
symbol : class gradeTypeLabel
location: class project2
gradeType = new gradeTypeLabel();
^
project2.java:44: cannot find symbol
symbol : class namePanel
location: class project2
name = new namePanel();
^
project2.java:46: cannot find symbol
symbol : class testPanel
location: class project2
test = new testPanel();
^
project2.java:78: cannot find symbol
symbol : class CalcButtonListener
location: class project2
calcButton.addActionListener(new CalcButtonListener());// calls the ActionListener for the calcButton
^
project2.java:79: cannot find symbol
symbol : class PrevButtonListener
location: class project2
prevButton.addActionListener(new PrevButtonListener());// calls the ActionListener for the prevButto
^
project2.java:80: cannot find symbol
symbol : class NextButtonListener
location: class project2
nextButton.addActionListener(new NextButtonListener());// calls the ActionListener for the nextButton
^
project2.java:81: cannot find symbol
symbol : class SaveButtonListener
location: class project2
saveButton.addActionListener(new SaveButtonListener());// calls the ActionListener for the addButton
^
13 errors

----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.

Most of those appear to be the same errors you posted before.
Where are the definitions for those missing classes?

The classes must be on the classpath for the compiler to find them.

Are any of the missing classes in packages?
Have you compiled all of the missing classes?
Were there any compilation errors when you compiled them?

I am lost...this is my second time taking this class. I am not a programmer but i had to take this class.

What happens if you put all of the classes in the same file?
Make sure that only one of the class definitions begins with "public" and that the filename is the same as that class.

can you show me?

//topClass.class

[U]public[/U] topClass
{

  class innerClass{//not public
  }

 class innerClass2{
  }


}

public class TheSameAsFilename {
... body of the class
} // end of class
// Here have some more classes all in the same .java file
class AnotherClass {
}
class AndAnotherClass {
}
class AndStillMore {
}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.