• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Invalid Symbol

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"))
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you mean to say


or perhaps:
 
Marshal
Posts: 80223
424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
    Marshal
    Posts: 80223
    424
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    It's a pleasure to help
     
    Willie Smits can speak 40 languages. This tiny ad can speak only one:
    Smokeless wood heat with a rocket mass heater
    https://woodheat.net
    reply
      Bookmark Topic Watch Topic
    • New Topic