I've looked the documentation on the subject and some exemples but I kind seem to find why the program doesn't work has intended.
I need to make a program with 6 choice, I'm using a Clavier.class which is a school made and approved class for reading user entry.
So fare I only made the first option, but when testing the program, if the input is 1, it doesn't go for the 1st loop, the program only stops after out-printing the user entry.
Here is the code so far(It's in french):
public class Facturation {
public static void main (String [] args) {
char Choix ;
int random;
final String MSG_PRESENTATION = "Programme de facturation a la minute pour"
+ "\n" + "la location de vehicules electriques. ";
final String MENU = "----"
+ "\n" + "MENU"
+ "\n" + "----"
+ "\n" + "1. Louer un vehicule"
+ "\n" + "2. Facturer la remise d'un vehicule"
+ "\n" + "3. Annuler une location"
+ "\n" + "4. Afficher le montant des recettes"
+ "\n"+ "5. Reinitialiser le montant des recettes"
+ "\n" + "6. Quitter le programme"
+ "\n" + "\n"+ "Entrez votre choix";
final String MSG1 = "LOCATION" ;
final String NOCAR1 = "Il n'y a plus de véhicules disponibles.";
System.out.println (MSG_PRESENTATION);
System.out.print (MENU + "\n") ;
Choix = Clavier.lireChar();
while (Choix >=1 && Choix <=6) ;
{
if (Choix == 1) {
System.out.println(MSG1);
double randomDouble = Math.random();
randomDouble = randomDouble * 4 + 1;
int randomInt = (int) randomDouble;
System.out.println(randomInt);
}
}
}
}
The first option generates a number from 1 to 4. I know the problem isn't with the number generator since I tried it in a separate class and it worked. The code compiles. I tried with switch/case and it didn't solve the problem. It will only show the menu at the beginning, and once the user types in "1", the program output 1 and stops.
Thanks.