Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Invalid Symbol

 
Eddy Ades
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
}
else
{
PrixUnitaireEnfant = prixUnitaireEnfantFinSemaine;
}
//Bloc dd calcul
} // main

} // test
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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"))
 
Arthur Blair
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you mean to say


or perhaps:
 
Campbell Ritchie
Sheriff
Posts: 48917
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

CR
  • 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
    Greenhorn
    Posts: 12
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks everyone for your replies,
    I will test everything as soons as I have a chance.
     
    Eddy Ades
    Greenhorn
    Posts: 12
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks for all your help,
    it's working fine,

    now I'm trying to finish my coding.

    thanks again

    Eddy
     
    Campbell Ritchie
    Sheriff
    Posts: 48917
    58
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    It's a pleasure to help
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic