# Grade Calculator Problems

• (4 Pages)
• 1
• 2
• 3
• Last »

## 57 Replies - 2383 Views - Last Post: 07 June 2010 - 03:14 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=176504&amp;s=9de8937e8240fb133474bbdec761b2bf&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 blknmld69

Reputation: -5
• Posts: 102
• Joined: 28-November 09

# Grade Calculator Problems

Posted 03 June 2010 - 09:49 AM

Im working on the same assignment. I am coming up with 19 errors.........This is a challenge and I have been working on it all day......Please someone get me started!
GradeCalculator.java:152: class, interface, or enum expected
public static void main (String [] args)
^
GradeCalculator.java:155: class, interface, or enum expected
}
^
GradeCalculator.java:161: class, interface, or enum expected
for (int s = 0; s < MAX_NUMBER_OF_STUDENTS; s++)
^
GradeCalculator.java:161: class, interface, or enum expected
for (int s = 0; s < MAX_NUMBER_OF_STUDENTS; s++)
^
GradeCalculator.java:161: class, interface, or enum expected
for (int s = 0; s < MAX_NUMBER_OF_STUDENTS; s++)
^
GradeCalculator.java:164: class, interface, or enum expected
^
GradeCalculator.java:166: class, interface, or enum expected
^
GradeCalculator.java:169: class, interface, or enum expected
^
GradeCalculator.java:170: class, interface, or enum expected
^
GradeCalculator.java:171: class, interface, or enum expected
}
^
GradeCalculator.java:174: class, interface, or enum expected
public void getStudentData(Scanner inFile)
^
GradeCalculator.java:177: class, interface, or enum expected
^
GradeCalculator.java:178: class, interface, or enum expected
}
^
GradeCalculator.java:202: class, interface, or enum expected
public void displayGradeAverage(String stName)
^
GradeCalculator.java:205: class, interface, or enum expected
String stName = "";
^
GradeCalculator.java:207: class, interface, or enum expected
boolean classAvg = studentList[totalScore / noOfStudents].getClassAverage();
^
GradeCalculator.java:209: class, interface, or enum expected
stNameTF.setText(studentList[stName].getFirstName() + " "
^
GradeCalculator.java:211: class, interface, or enum expected
stAvgTF.setText(""+studentList[totalScore / 5.0].getStudentAverage());
^
GradeCalculator.java:212: class, interface, or enum expected
classAvgTF.setText(""+studentList[totalScore / noOfStudents].getClassAverage());
^
19 errors

Is This A Good Question/Topic? 0

## Replies To: Grade Calculator Problems

### #2 japanir

• jaVanir

Reputation: 1012
• Posts: 3,025
• Joined: 20-August 09

## Re: Grade Calculator Problems

Posted 03 June 2010 - 01:23 PM

blknmld69 better open your own thread, and post your code, along with those error messages.

### #3 pbl

• There is nothing you can't do with a JTable

Reputation: 8362
• Posts: 31,955
• Joined: 06-March 08

## Re: Grade Calculator Problems

Posted 03 June 2010 - 06:48 PM

95% of the time the error: class, interface, or enum expected
comes from unbalenced {}
indent your code properly and the errors will come obvious

Edited by macosxnerd101: I removed the code you indented because I see in another thread which I'm about to merge that this wasn't the OP's code.

This post has been edited by macosxnerd101: 06 June 2010 - 12:28 PM

### #4 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11315
• Posts: 42,619
• Joined: 27-December 08

## Re: Grade Calculator Problems

Posted 04 June 2010 - 05:38 PM

I agree with japanir. Topic split.

@blknmld69: Please avoid necroposting. Also, are these errors from your code or from the OP of the thread you posted in?

### #5 blknmld69

Reputation: -5
• Posts: 102
• Joined: 28-November 09

## Re: Grade Calculator Problems

Posted 06 June 2010 - 09:46 AM

I need help on the file I attached. Its due tomorrow by 10am. Can someone get me started and help me throughout the day. I have been busy studying for my other classes and gettn my other program done. I know i shouldnt have excuses but its exams time!!!!!!

Desperate to get at least something done. Any help would be greatly appreciated!!!!!!!!!!

### #6 m-e-g-a-z

• Winning

Reputation: 497
• Posts: 1,453
• Joined: 19-October 09

## Re: Grade Calculator Problems

Posted 06 June 2010 - 10:05 AM

Could you post your code in the brackets below as its easier and safer for us to access your code.

### #7 Ember

Reputation: 70
• Posts: 160
• Joined: 24-April 10

## Re: Grade Calculator Problems

Posted 06 June 2010 - 10:12 AM

Well, let's start off with #1 on the list. Create a Student Class:

```public class Student{
//Put a string of the student's name here
//Create an array of integers of size 3 here

public Student(Put Parameters here){
//Initialize fields above with the parameters you put in.
}

public int getGrades(put int param here){
//get the corresponding index and return an int value of that grade
}

public void setGrades(put int param here, put grade int here){
//set the grade based on the corresponding index, won't return anything
}

//Continue doing this with all the accessors~~~~~~~~~~~

```

I think I broke a few rules by posting just this so..yea. We at D.I.C. aren't really supposed to help you if you don't put any effort into trying to solve a problem first. I am assuming you just don't know where to start which is why I created this partial format for you to follow.

Have fun, it won't be too hard if you power through it all in one run.

### #8 blknmld69

Reputation: -5
• Posts: 102
• Joined: 28-November 09

## Re: Grade Calculator Problems

Posted 06 June 2010 - 11:24 AM

You assumed correct.....I will start with that. The only thing I had started was the GUI. I will work on it for a few hours and get back with you! Thanks

### #9 blknmld69

Reputation: -5
• Posts: 102
• Joined: 28-November 09

## Re: Grade Calculator Problems

Posted 06 June 2010 - 12:23 PM

what is necroposting?

### #10 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11315
• Posts: 42,619
• Joined: 27-December 08

## Re: Grade Calculator Problems

Posted 06 June 2010 - 12:32 PM

Topics merged. Please avoid duplicate posting.

Necroposting is where you post in a dead thread. Really, any thread that isn't on the first two pages on the Java forum is considered dead.

### #11 blknmld69

Reputation: -5
• Posts: 102
• Joined: 28-November 09

## Re: Grade Calculator Problems

Posted 06 June 2010 - 12:40 PM

ok sorry!!!!!!!!!

### #12 pbl

• There is nothing you can't do with a JTable

Reputation: 8362
• Posts: 31,955
• Joined: 06-March 08

## Re: Grade Calculator Problems

Posted 06 June 2010 - 05:03 PM

macosxnerd101, on 06 June 2010 - 01:32 PM, said:

Topics merged. Please avoid duplicate posting.

Necroposting is where you post in a dead thread. Really, any thread that isn't on the first two pages on the Java forum is considered dead.

Don't exagerate Mac, I spend 1 hour a day to answer unanswered posts in all in the fist 4 pages Whish somebody else will do as I do

### #13 blknmld69

Reputation: -5
• Posts: 102
• Joined: 28-November 09

## Re: Grade Calculator Problems

Posted 06 June 2010 - 05:32 PM

someone please help me with all these errors. Been working on this allday and my eyes are crossed. Its due tomorrow at 10am. Lord Help me Please!!!!!!!!!!!!!!!!!

```   import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class GradeCalculator extends JFrame
{
private static final int WIDTH = 550;
private static final int HEIGHT = 430;

private static final int MAX_NUMBER_OF_STUDENTS = 20;

// instance variables
private Student[] Student = new Student[MAX_NUMBER_OF_STUDENTS];
private int noOfStudents;
private double score, tst1, tst2, tst3;
private double  classAvg, stAvg, totalScore;
private int displayedStudentIndex = 0;
private String stName;

// This area is for the GUI components
// Each item that will be displayed will
// have a label and a textfield, (L) and (TF),
// respectively.
private JLabel stNameL, tst1L, tst2L, tst3L,
private JTextField stNameTF, tst1TF, tst2TF, tst3TF;
private JTextArea classAvgTA, stAvgTA;
private JButton exitB, nextB, prevB, calcGrade;

private ButtonHandler bHandler;

{
setTitle("Grade Calculator");           // set's the title
setSize(WIDTH, HEIGHT);                 // set the window size
Container pane = getContentPane();      // get the container
pane.setLayout(null);                   // set the container's layout to null

bHandler = new ButtonHandler();         // instantiate the button event handler

// instantiate the labels
headingL = new JLabel("STUDENT RECORD");
stNameL = new JLabel("Studen Name", SwingConstants.RIGHT);
tst1L = new JLabel("Test 1", SwingConstants.LEFT);
tst2L = new JLabel("Test 2", SwingConstants.LEFT);
tst3L = new JLabel("Test 3", SwingConstants.LEFT);
stAvgL = new JLabel("Student Average     "
+ "\n"   + "Class Average");
//instantiate the text fields
stNameTF = new JTextField(65);
tst1TF = new JTextField(10);
tst2TF = new JTextField(10);
tst3TF = new JTextField(10);

// instantiate the text area
classAvgTA = new JTextArea(6, 20);
classAvgTA.setAutoscrolls(true);

// instantiate the buttons and register the listener
exitB = new JButton("Exit");

nextB = new JButton("Next");

prevB = new JButton("Previous");

// set the size of the labels, text fields, and buttons

stNameL.setSize(100, 30);
stNameTF.setSize(100, 30);
tst1L.setSize(100, 30);
tst1TF.setSize(100, 30);
tst2L.setSize(120, 30);
tst2TF.setSize(100, 30);
tst3L.setSize(100, 30);
tst3TF.setSize(100, 30);
classAvgTA.setSize(370, 120);
prevB.setSize(100, 30);
nextB.setSize(100, 30);
exitB.setSize(100, 30);

//set the location of the labels, text fields,
//and buttons
stNameL.setLocation(20, 50);
stNameTF.setLocation(120, 50);
tst1L.setLocation(20, 100);
tst1TF.setLocation(120, 100);
tst2L.setLocation(300, 50);
tst2TF.setLocation(420, 50);
tst3L.setLocation(300, 100);
tst3TF.setLocation(420, 100);
classAvgTA.setLocation(70, 230);
prevB.setLocation(120, 370);
exitB.setLocation(220, 370);
nextB.setLocation(320, 370);

//add the labels, text fields, and buttons to the pane

setVisible(true); 		//show the window
setDefaultCloseOperation(EXIT_ON_CLOSE);
System.exit(0);
}

public static void main (String [] args)
{
}

Scanner inFile =
{
for (int s = 0; s < MAX_NUMBER_OF_STUDENTS; s++)
gradeCalc.studentList[s] = new Student();

inFile.nextInt();       // get the number of students
inFile.nextDouble();    // get the student's scores

}

// get the student data from file

public void getStudentData(Scanner inFile)
{
System.out.println("Grade Calculator is getting information...");
}
private class ButtonHandler implements ActionListener
{
public void actionPerformed (ActionEvent e)
{
if (e.getActionCommand().equals("Previous"))
if (displayedStudentIndex > 0)
else
else if (e.getActionCommand().equals("Next"))
if (displayedStudentIndex + 1 < noOfStudents)
else
else if (e.getActionCommand().equals("Calc Grade"))
else
System.exit(0);
}
}

public void displayGradeAverage(String stName)
{
displayedStudentIndex = stName;
String stName = "";

boolean classAvg = studentList[totalScore / noOfStudents].getClassAverage();

stNameTF.setText(studentList[stName].getFirstName() + " "
+ studentList[stName].getLastName());
stAvgTF.setText(""+studentList[totalScore / 5.0].getStudentAverage());
classAvgTF.setText(""+studentList[totalScore / noOfStudents].getClassAverage());

}

}

```

ERRORS
----jGRASP exec: javac -g I:\DTC\Spring 2010\Java\GradeCalculator.java

GradeCalculator.java:13: cannot find symbol
symbol : class Student
private Student[] Student = new Student[MAX_NUMBER_OF_STUDENTS];
^
GradeCalculator.java:136: cannot find symbol
symbol : class Scanner
Scanner inFile =
^
GradeCalculator.java:154: cannot find symbol
symbol : class Scanner
public void getStudentData(Scanner inFile)
^
GradeCalculator.java:13: cannot find symbol
symbol : class Student
private Student[] Student = new Student[MAX_NUMBER_OF_STUDENTS];
^
GradeCalculator.java:137: cannot find symbol
symbol : class Scanner
^
GradeCalculator.java:137: cannot find symbol
symbol : class FileReader
^
GradeCalculator.java:140: cannot find symbol
symbol : variable gradeCalc
gradeCalc.studentList[s] = new Student();
^
GradeCalculator.java:140: cannot find symbol
symbol : class Student
gradeCalc.studentList[s] = new Student();
^
GradeCalculator.java:142: cannot find symbol
symbol : variable gradeCalc
^
GradeCalculator.java:144: cannot find symbol
symbol : variable gradeCalc
^
GradeCalculator.java:147: cannot find symbol
symbol : variable gradeCalc
^
GradeCalculator.java:148: cannot find symbol
symbol : variable gradeCalc
^
^
^
^
^
^
found : java.lang.String
required: int
displayedStudentIndex = stName;
^
String stName = "";
^
GradeCalculator.java:185: cannot find symbol
symbol : variable studentList
boolean classAvg = studentList[totalScore / noOfStudents].getClassAverage();
^
GradeCalculator.java:185: possible loss of precision
found : double
required: int
boolean classAvg = studentList[totalScore / noOfStudents].getClassAverage();
^
GradeCalculator.java:187: cannot find symbol
symbol : variable studentList
stNameTF.setText(studentList[stName].getFirstName() + " "
^
found : java.lang.String
required: int
stNameTF.setText(studentList[stName].getFirstName() + " "
^
GradeCalculator.java:188: cannot find symbol
symbol : variable studentList
+ studentList[stName].getLastName());
^
found : java.lang.String
required: int
+ studentList[stName].getLastName());
^
GradeCalculator.java:189: cannot find symbol
symbol : variable studentList
stAvgTF.setText(""+studentList[totalScore / 5.0].getStudentAverage());
^
GradeCalculator.java:189: possible loss of precision
found : double
required: int
stAvgTF.setText(""+studentList[totalScore / 5.0].getStudentAverage());
^
GradeCalculator.java:189: cannot find symbol
symbol : variable stAvgTF
stAvgTF.setText(""+studentList[totalScore / 5.0].getStudentAverage());
^
GradeCalculator.java:190: cannot find symbol
symbol : variable studentList
classAvgTF.setText(""+studentList[totalScore / noOfStudents].getClassAverage());
^
GradeCalculator.java:190: possible loss of precision
found : double
required: int
classAvgTF.setText(""+studentList[totalScore / noOfStudents].getClassAverage());
^
GradeCalculator.java:190: cannot find symbol
symbol : variable classAvgTF
classAvgTF.setText(""+studentList[totalScore / noOfStudents].getClassAverage());
^
31 errors

### #14 macosxnerd101

• Games, Graphs, and Auctions

Reputation: 11315
• Posts: 42,619
• Joined: 27-December 08

## Re: Grade Calculator Problems

Posted 06 June 2010 - 05:38 PM

Duplicate Topics Merged. Please stop opening up duplicate threads.

Just some quick things I noticed while glancing through. First, you can fix your errors with Scanner and FileReader by importing java.util.* and java.io.*. Next, your class Student doesn't seem to be in visible scope for the GradeCalculator class.

Also, it isn't a good idea to name your array or any variable the same as the type, like you do here: Student[] Student.

### #15 m-e-g-a-z

• Winning

Reputation: 497
• Posts: 1,453
• Joined: 19-October 09

## Re: Grade Calculator Problems

Posted 06 June 2010 - 05:41 PM

No need to shout blknmld69.

Most of these errors are because you are using the wrong type.

e.g Line 190

found : double
required: int

This post has been edited by m-e-g-a-z: 06 June 2010 - 05:54 PM