Some more errors

GUIGradeApp.java:26: cannot find symbol

symbol : class Valdiator

location: class GUIGradeApp

Validator something = new Valdiator();

^

Validator.java:9: cannot find symbol

symbol : variable userEntry

location: class Validator

userEntry = Double.parseDouble(dataEntry);

^

Validator.java:10: cannot find symbol

symbol : variable userEntry

location: class Validator

if (userEntry > 100.00 || userEntry < 0.0)

^

Validator.java:10: cannot find symbol

symbol : variable userEntry

location: class Validator

if (userEntry > 100.00 || userEntry < 0.0)

^

Validator.java:18: cannot find symbol

symbol : variable strthirdMessage

location: class Validator

dataEntry = JOptionPane.showInputDialog(strthirdMessage, JOptionPane.ERROR_MESSAGE);

^

Validator.java:18: cannot find symbol

symbol : variable JOptionPane

location: class Validator

dataEntry = JOptionPane.showInputDialog(strthirdMessage, JOptionPane.ERROR_MESSAGE);

^

Validator.java:18: cannot find symbol

symbol : variable JOptionPane

location: class Validator

dataEntry = JOptionPane.showInputDialog(strthirdMessage, JOptionPane.ERROR_MESSAGE);

^

Validator.java:21: incompatible types

found: java.lang.String

required: double

return dataEntry;

and here is the code

//Thomas Tate

//Project 2 -GUI

import javax.swing.*;

import java.util.*;

publicclass GUIGradeApp

{

publicstaticvoid main(String[] args)

{

//defines variables

double userEntry = 0;

String dataEntry ="tyt";

double gradeTotal = 0;

double highest = 0;

double lowest = 99999.0;

double gradeAverage = 0;

int gradeCount = 0;

String letterGrade ="";

//gets inout from the user

String strFirstMessage = ("Please enter a test score");

dataEntry = JOptionPane.showInputDialog(strFirstMessage, JOptionPane.ERROR_MESSAGE);

Validator something =new Valdiator();

something.getIsValid(dataEntry);

gradeTotal = gradeTotal + userEntry;

gradeCount = gradeCount + 1;

highest = Math.max(highest, userEntry);

lowest = Math.min(lowest, userEntry);

String strSecondMessage = ("Please enter a test score,\n or 'x' to view data results.");

dataEntry = JOptionPane.showInputDialog(strSecondMessage, JOptionPane.ERROR_MESSAGE);

//creates letter grade

gradeAverage = gradeTotal / gradeCount;

if (gradeAverage <= 89.5 || gradeAverage >= 100.00)

letterGrade ="A";

elseif (gradeAverage <= 79.5 || gradeAverage > 89.5)

letterGrade ="B";

elseif (gradeAverage <= 69.5 || gradeAverage > 79.5)

letterGrade ="C";

elseif (gradeAverage <= 59.5 || gradeAverage > 69.5)

letterGrade ="D";

else

letterGrade ="F";

String strThirdMessage ="Number of scores: " + gradeCount +"\n"

+"Average score: " + gradeAverage +"\n"

+"Letter Grade: " + letterGrade +"\n"

+"Best score: " + highest +"\n"

+"Press enter to continue entering scores,\nor 'x' to exit.";

JOptionPane.showInputDialog(strThirdMessage, JOptionPane.ERROR_MESSAGE);

}

}

[4845 byte] By [jeezaha] at [2007-11-27 2:22:46]
# 1

You have some general scoping issues in your code. Define your variables as member variables, not as instance variables. I.e. remove them from your main method and place them in your Class definition.

Validator something = new Valdiator();

Notice anything wrong?

Also, you need to declare a new JOptionPane. You can't just say JOptionPane.showInputDialog, you need to create a new JOptionPane object, *then* call its methods.

Also, when you're naming objects, make the name relevant. "something" is not a good name. Try "validator" instead.

Message was edited by:

Djaunl

Djaunla at 2007-7-12 2:27:36 > top of Java-index,Java Essentials,New To Java...
# 2

> You have some general scoping issues in your code.

> Define your variables as member variables, not as

> instance variables. I.e. remove them from your main

> method and place them in your Class definition.

>

> Validator something = new Valdiator();

> Notice anything wrong?

>

> Also, you need to declare a new JOptionPane. You

> can't just say JOptionPane.showInputDialog, you need

> to create a new JOptionPane object, *then* call its

> methods.

Eh? I've not read through this code, but JOptionPane has losts of static methods to do just this.

tsitha at 2007-7-12 2:27:36 > top of Java-index,Java Essentials,New To Java...
# 3
> Eh? I've not read through this code, but JOptionPane> has losts of static methods to do just this.Well I'm probably wrong then. I didn't really think of that. I assumed that would be the problem.Just checked the API, oops.
Djaunla at 2007-7-12 2:27:36 > top of Java-index,Java Essentials,New To Java...
# 4

Check my comments - then compare to your code:

import javax.swing.*;

import java.util.*;

public class GUIGradeApp

{

public static void main(String[] args)

{

//defines variables

double userEntry = 0;

String dataEntry = "tyt";

double gradeTotal = 0;

double highest = 0;

double lowest = 99999.0;

double gradeAverage = 0;

int gradeCount = 0;

String letterGrade = "";

//gets inout from the user

String strFirstMessage = ("Please enter a test score");

dataEntry = JOptionPane.showInputDialog(strFirstMessage, ""+JOptionPane.ERROR_MESSAGE); // Make it a String, which is an Object

Validator something = new Validator(); // spelling!

something.getIsValid(dataEntry);

gradeTotal = gradeTotal + userEntry;

gradeCount = gradeCount + 1;

highest = Math.max(highest, userEntry);

lowest = Math.min(lowest, userEntry);

String strSecondMessage = ("Please enter a test score,\n or 'x' to view data results.");

dataEntry = JOptionPane.showInputDialog(strSecondMessage, ""+JOptionPane.ERROR_MESSAGE); // Make it a String

//creates letter grade

gradeAverage = gradeTotal / gradeCount;

if (gradeAverage <= 89.5 || gradeAverage >= 100.00)

letterGrade = "A";

else if (gradeAverage <= 79.5 || gradeAverage > 89.5)

letterGrade = "B";

else if (gradeAverage <= 69.5 || gradeAverage > 79.5)

letterGrade = "C";

else if (gradeAverage <= 59.5 || gradeAverage > 69.5)

letterGrade = "D";

else

letterGrade = "F";

String strThirdMessage = "Number of scores: " + gradeCount + "\n"

+ "Average score: " + gradeAverage + "\n"

+ "Letter Grade: " + letterGrade +"\n"

+ "Best score: " + highest + "\n"

+ "Press enter to continue entering scores,\nor 'x' to exit.";

JOptionPane.showInputDialog(strThirdMessage, ""+JOptionPane.ERROR_MESSAGE); // Make it a String

}

}

It still can't see class Validator. You had misspelled it as Valdiator, but I don't know where it is at any rate.

Oh [url http://forum.java.sun.com/thread.jspa?threadID=5165336&tstart=0]here[/url] it is!

abillconsla at 2007-7-12 2:27:36 > top of Java-index,Java Essentials,New To Java...
# 5
No thanks?
abillconsla at 2007-7-12 2:27:36 > top of Java-index,Java Essentials,New To Java...