wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Invalid Symbol Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Invalid Symbol" Watch "Invalid Symbol" New topic

Invalid Symbol

Eddy Ades

Joined: Nov 14, 2005
Posts: 12
Hello everyone,

I'm having an issue when compiling the code.
I get Invalid Symbol - LU

I added the code, but the constant and variables are in French (my Java class is in French !!!)
But it's pretty easy to understand. I already made couple exercices, which was fine, but now I'm having issues with my IF statement.

The users needs to enter LU (which is Lundi(monday), MA for Mardi(tuseday and so on)and from them there is bunch of calculation...

But when I wrote If (jourSemaine = LU)
{ ....
else if (.....)

When compiling (using Blue J) I get the error "Invalid Symbol - LU"
Also it's a Do - While syntax, but the while is not there yet...

I would really appreciate if somebody can guide me trough this.

Here's my code

public class test {

// Autres m�thodes s'il y a lieu

public static void main (String[] params) {
final String lundi = "LU";
final String mardi = "MA";
final String mercredi = "ME";
final String jeudi = "JU";
final String vendredi = "VE";
final String samedi = "SA";
final String dimanche = "DI";
final double prixUnitaireEnfantSemaine = 10.0;
final double prixUnitaireEtudiantSemaine = 17.0;
final double prixUnitaireAdulteSemaine = 26.0;
final double prixUnitaireAgeDorSemaine = 19.0;
final double prixUnitaireFamilleSemaine = 65.0;
final double prixUnitaireEnfantFinSemaine = 13.0;
final double prixUnitaireEtudiantFinSemaine = 19.0;
final double prixUnitaireAdulteFinSemaine = 29.0;
final double prixUnitaireAgeDorFinSemaine = 21.0;
final double prixUnitaireFamilleFinSemaine = 76.0;
String jourSemaine;
double PrixUnitaireEnfant;
double PrixUnitaireEtudiant;
double PrixUnitaireAdulte;
double PrixUnitaireFamille;
double PrixUnitaireAgeDor;
int nbBilletFamille;
int nbBilletEnfant;
int nbBilletEtudiant;
int nbBilletAdulte;
int nbBilletAgeDor;
int nbBilletTotalBilletParJour;
double montantBilletEnfant;
double montantBilletEtudiant;
double montantBilletAdulte;
double montantBilletFamille;
double montantBilletAgeDor;
double montantTotalBillet;
double montantTPS;
double montantTVQ;
double montantTotalFacture;
System.out.print("Entrez le jour de la visite:");
System.out.println("LU=Lundi, MA=Mardi, ME=Mercredi, JE=Jeudi, VE=Vendredi, SA=Samedi ou DI=Dimanche:");
jourSemaine = Clavier.lireString();
//Nombre de Billets pour chaque groupe d'�ge
System.out.print("Entre le nombre de billets pour laissez-passer famille:");
nbBilletFamille = Clavier.lireInt();
System.out.print("Entre le nombre de billets pour les enfants (de 10 ans et moins):");
nbBilletEnfant = Clavier.lireInt();
System.out.print("Entre le nombre de billets pour les Etudiants (de 11 a 17 ans):");
nbBilletEtudiant = Clavier.lireInt();
System.out.print("Entre le nombre de billets pour les Adultes (de 18 a 64 ans):");
nbBilletAdulte = Clavier.lireInt();
System.out.print("Entre le nombre de billets pour les Ainees (65 ans et plus):");
nbBilletAgeDor = Clavier.lireInt();
if (jourSemaine = LU)
PrixUnitaireEnfant = prixUnitaireEnfantSemaine;
PrixUnitaireEnfant = prixUnitaireEnfantFinSemaine;
//Bloc dd calcul
} // main

} // test
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24166


Welcome to JavaRanch!

LU is the name of a variable or class. Since there is no such variable or class, you're getting this error.

I think you mean to compare a variable to the String "LU". You need to use those double quotes any time you include an actual String in your code.

Now, given that: the way to compare two Strings is with the equals() method. The line you've written as

if (jourSemaine = LU)

must instead be

if (jourSemaine.equals("LU"))

[Jess in Action][AskingGoodQuestions]
Arthur Blair
Ranch Hand

Joined: Sep 20, 2005
Posts: 71
I think you mean to say

or perhaps:
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 36482
You can't put an = after if. It would have to be a==.
And that won't work, because all you do is try out whether jourSemaine is the same object as "LU," whihc it obviously isn't

What you actually want is

And why are you putting all your fields inside the main(String[] args) method?

  • You ought only to use your main method to start the program off, not to contain any actual processing,
  • and, you have declared LU MA ME etc as local variables in the main method, so they would not be visible to other methods in your class
  • Eddy Ades

    Joined: Nov 14, 2005
    Posts: 12
    Thanks everyone for your replies,
    I will test everything as soons as I have a chance.
    Eddy Ades

    Joined: Nov 14, 2005
    Posts: 12
    Thanks for all your help,
    it's working fine,

    now I'm trying to finish my coding.

    thanks again

    Campbell Ritchie

    Joined: Oct 13, 2005
    Posts: 36482
    It's a pleasure to help
    I agree. Here's the link: http://aspose.com/file-tools
    subject: Invalid Symbol
    Similar Threads
    Class (Day)
    Problem while executing the program
    Creating a class
    executing the program.
    Syntax problem