Eddy Ades

Greenhorn
+ Follow
since Nov 14, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Eddy Ades

Hi,

I created 3 classes + one main class. (sorry again, it's all in french !! French java class)
I have a class named Journee (Day), another one named Billet (ticket) and another on called Facture(billing) and the main class is called Safari.

I believe that my Journee and Billet class are ok
and even thought I'm able to compile the Facture class, I guess there is something missing.

The main class Safari should be able to get the info from Facture,

When I execute the program I'm able to write down the day and how many tickets but after entering the tickets it should be able to make the calculation but it's not the case.

What is wrong and how can I write it down ??

Here's all my info

1- Class (Journee)
public class Journee {

// Autres m�thodes s'il y a lieu
public static final String LU = "lundi";
public static final String MA = "mardi";
public static final String ME = "mercredi";
public static final String JE = "jeudi";
public static final String VE = "vendredi";
public static final String SA = "samedi";
public static final String DI = "dimanche";
// variable(s) d'instance s'il y a lieu (attributs)
private String jourDeLaSemaine; //lu= lundi, ma...

// constructeur(s) s'il y a lieu
public Journee(String jourDeLaSemaine){
this.jourDeLaSemaine = jourDeLaSemaine;
}


// m�thode(s) d'instance s'il y a lieu
//getters-setters
public String getJourDeLaSemaine(String jourDeLaSemaine){
return new String(jourDeLaSemaine);
}

public void setJourDeLaSemaine(String jourSemaine){
jourDeLaSemaine= new String(jourSemaine);
}

public boolean estFinDeSemaine(){
return (jourDeLaSemaine.compareTo(SA)==0) ||
(jourDeLaSemaine.compareTo(DI)==0);

}

public boolean estJourneeValide(){
return (jourDeLaSemaine.compareTo(LU)==0) ||
(jourDeLaSemaine.compareTo(MA)==0)||
(jourDeLaSemaine.compareTo(ME)==0) ||
(jourDeLaSemaine.compareTo(JE)==0)||
(jourDeLaSemaine.compareTo(VE)==0) ||
(jourDeLaSemaine.compareTo(SA)==0) ||
(jourDeLaSemaine.compareTo(DI)==0);

}
} // journ�e

2- Class (Billet)

public class Billets {



// Autres m�thodes s'il y a lieu
public static final double prixSemaineEnfant = 10.0;
public static final double prixFinSemaineEnfant = 13.0;

public static final double prixSemaineEtudiant = 17.0;
public static final double prixFinSemaineEtudiant = 19.0;

public static final double prixSemaineAdulte = 26.0;
public static final double prixFinSemaineAdulte = 29.0;

public static final double prixSemaineAgeOr = 19.0;
public static final double prixFinSemaineAgeOr = 21.0;

public static final double prixSemaineFamille = 65.0;
public static final double prixFinSemaineFamille = 76.0;

public static final int nombreBilletMax = 500;
// variable(s) d'instance s'il y a lieu (attributs)
private int nombreBilletEnfant; // nombre de billets pour le groupe �ge enfant
private int nombreBilletEtudiant; // nombre de billets pour le groupe �ge �tudiant
private int nombreBilletAdulte; // nombre de billets pour le groupe �ge adulte
private int nombreBilletAgeOr; // nombre de billets pour le groupe �ge d'or


// constructeur(s) s'il y a lieu
public Billets( int nombreBilletEnfant, int nombreBilletEtudiant,
int nombreBilletAdulte, int nombreBilletAgeOr){

//initialisation des variables
this.nombreBilletEnfant = nombreBilletEnfant; //
this.nombreBilletEtudiant = nombreBilletEtudiant; //
this.nombreBilletAdulte = nombreBilletAdulte; //
this.nombreBilletAgeOr = nombreBilletAgeOr;



}

// m�thode(s) d'instance s'il y a lieu
//getters-setters

public boolean verifierBilletsDisponibles(int nombreTotalBilletsVendus){
int nombreBilletsDisponible;


nombreTotalBilletsVendus = this.nombreBilletEnfant +
this.nombreBilletEtudiant +
this.nombreBilletAdulte +
this.nombreBilletAgeOr;

nombreBilletsDisponible = nombreBilletMax -
nombreTotalBilletsVendus;




return nombreBilletMax - nombreTotalBilletsVendus > 0;

}
public int getNombreBilletEnfant() {
return nombreBilletEnfant;
}

public int getNombreBilletEtudiant() {
return nombreBilletEtudiant;
}
public int getNombreBilletAdulte() {
return nombreBilletAdulte;
}

public int getNombreBilletAgeOr() {
return nombreBilletAgeOr;
}
public void setNombreBilletEnfant() {
this.nombreBilletEnfant = nombreBilletEnfant ;
}

public void setNombreBilletEtudiant() {
this.nombreBilletEtudiant = nombreBilletEtudiant ;
}
public void setNombreBilletAdulte() {
this.nombreBilletAdulte = nombreBilletAdulte;
}

public void setNombreBilletAgeOr() {
this.nombreBilletAgeOr = nombreBilletAgeOr;
}

public void calculerNombreBilletsAchetes (){
int nombreTotalBilletsVendus;
nombreTotalBilletsVendus = this.nombreBilletEnfant +
this.nombreBilletEtudiant +
this.nombreBilletAdulte +
this.nombreBilletAgeOr;
}




} // billets

3- Class (Facture)

public class Facture {

final String SA = "samedi";
final String DI = "dimanche";
int nombreBilletEnfant; // nombre de billets pour le groupe �ge enfant
int nombreBilletEtudiant; // nombre de billets pour le groupe �ge �tudiant
int nombreBilletAdulte; // nombre de billets pour le groupe �ge adulte
int nombreBilletAgeOr; // nombre

// Autres m�thodes s'il y a lieu
// membres de classe
public static final double tauxTps = 0.07;
public static final double tauxTvq = 0.075;



// membres d'instance
private Journee journee;// contient toutes les informations sur le jour de la visite
private Billets billet; // contient toutes les informations sur les billets
private double montantVente; // repr�sente le montant de vente avant taxes
private double montantTps; // repr�sente le montant de la taxe TPS
private double montantTvq; // repr�sente le montant de la taxe TVQ double
private double montantTotal; // repr�sente le montant total

//constructeur
public Facture(Journee journee, Billets billet){
this.journee = journee;
this.billet = billet;
double montantVente = 0;
double montantTps = 0;
double montantTvq = 0;
double montantTotal = 0;

}
//methodes d'instance





public void calculerMontantAvantTaxe(){

if ( journee.estFinDeSemaine()) {
montantVente = billet.getNombreBilletEnfant() * billet.prixFinSemaineEnfant +
billet.getNombreBilletEtudiant() * billet.prixFinSemaineEtudiant +
billet.getNombreBilletAdulte() *billet.prixFinSemaineAdulte +
billet.getNombreBilletAgeOr() * billet.prixFinSemaineAgeOr ;
}
}

public void calculerMontantTps(){

montantTps = montantVente * tauxTps;
}
public void calculerMontantTvq(){

montantTvq =( montantVente + montantTps) * tauxTvq ;
}
public void calculerMontantTotal(){
montantTotal = montantVente +
montantTps +
montantTvq;
}




public void afficher(){

System.out.print("\n\nLe montant vente est : ");
System.out.println(montantVente);

System.out.print("\n\nLe montant TPS est : ");
System.out.println(montantTps);

System.out.print("\n\nLe montant TVQ est : ");
System.out.println(montantTvq);

System.out.print("\n\nLe montant total est : ");
System.out.println(montantTotal);
System.out.println();

billet.calculerNombreBilletsAchetes ();





}





} // facture

And Finaly

the Main class

public class Safari {
static void presenterLogiciel(){
System.out.println("bienvenue au parc safari");
System.out.println("ce logiciel permet de calculer la facture de billets d'entr�e au parc");
System.out.println("r�alis� par Ait kerrane Redouane");
System.out.println("versin:1.01");
System.out.println();
}// fin de presenterLogiciel





public static void main (String[] params) {



//d�claration des variables

int nombreBilletsEnfant =0;
int nombreBilletsEtudiant =0;
int nombreBilletsAdulte =0;
int nombreBilletsAgeOr =0;
int nombreTotalDeBilletsVendus=0;
int nombreDeBilletsDisponible= 0;
double montantBillets =0;
double montantTotalFacture=0;
double tps=0;
double tvq=0;
Billets billet;
//billet = new Billets();
char Reponse ;
String jourSemaine ;


//d�but
// appel de la m�thode
presenterLogiciel();


do
{
//bloc de saisie






int Entree1 = 0;
int Entree2 = 0;
int Entree3 = 0;
int Entree4 = 0;




System.out.println("entrez le jour de la semaine:");
jourSemaine =Clavier.lireString();

//billet.verifierBilletsDisponibles();


while(true){
try{
System.out.println("Entrez le nombre de billets Enfant(10 ans et moins):");
Entree1 = Clavier.lireInt();
nombreBilletsEnfant = nombreBilletsEnfant + Entree1;

//nombreBilletsEnfant = billet.getNombreBilletEnfant(); //
break;
} catch(NumberFormatException e){
System.out.println("nombre invalide");
}
}
while(true){
try{
System.out.println("Entrez le nombre de billets Etudiant(11 � 17 ans):");
Entree2 = Clavier.lireInt();
nombreBilletsEtudiant = nombreBilletsEtudiant + Entree2;
// nombreBilletsEtudiant = billet.getNombreBilletEtudiant();
break;
} catch(NumberFormatException e){
System.out.println("nombre invalide");
}
}

while(true){
try{
System.out.println("Entrez le nombre de billets Adulte(18 � 64 ans):");
Entree3 = Clavier.lireInt();
nombreBilletsAdulte = nombreBilletsAdulte + Entree3;
//nombreBilletsAdulte = billet.getNombreBilletAdulte();
break;
} catch(NumberFormatException e){
System.out.println("nombre invalide");
}
}

while(true){
try{
System.out.println("Entrez le nombre de billets Age or(65 ans et plus):");
Entree4 = Clavier.lireInt();
nombreBilletsAgeOr = nombreBilletsAgeOr + Entree4;
//nombreBilletsAgeOr = billet.getNombreBilletAgeOr();
break;
} catch(NumberFormatException e){
System.out.println("nombre invalide");
}
}
billet = new Billets(nombreBilletsEnfant,nombreBilletsEtudiant,nombreBilletsAdulte,nombreBilletsAgeOr);


//bloc de traitement

//d�terminer le prix unitaire de chaque cat�gorie de billetsen fonction de jour de la semaine

//jour de la semaine(du lundi au vendredi)



//bloc d'affichage


SimpleDateFormat formatDate = new SimpleDateFormat("dd-MM-yyyy"); // format de date
Date dateSysteme = new Date();// Cr�ation d'un objet date

System.out.print(" La date : ");// La date du syst�me
System.out.println(formatDate.format(dateSysteme));
System.out.println();

System.out.println("Voulez-vous continuer(y/n)?");
Reponse = Clavier.lireChar();




} while((Reponse == 'y' || Reponse == 'Y'));

}
// main

} // Safari



Thanks
Ed
19 years ago
I have a class (name Journee (means Day)
Now I'm trying to say in class method and my instances method
if they select Saturday or Sunday this means weekend

and in my other method I have to say if it's not Saturday or sunday then it equald a weekday.

The main problem that I have, is I have no idea how to code this.
I tried couple thing, but I'm looking (probably at the wrong place) I would really appreciate some help
I tried writing a few stuff but it dosen't hurt !!

here what I have so far ( it's all in french tough!!)


public class Journee {

// Cette classe contient l'information sur le jour de la semaine inscrit

// variable(s) de classe s'il y a lieu
final public static String Lundi = "lu";
final public static String Mardi = "ma";
final public static String Mercredi = "me";
final public static String Jeudi = "ju";
final public static String Vendredi = "ve";
final public static String Samedi = "sa";
final public static String Dimanche = "di";
public String Journee;

// variable(s) d'instance s'il y a lieu
private String jourDeLaSemaine;

// constructeur(s) s'il y a lieu
public Journee (String jourDeLaSemaine){
Journee = new String ();
}
// m�thode(s) de classe s'il y a lieu
// Permet de v�rifier si le jour de la semaine entr�e est Sa ou Di
public boolean equals (Journee j1){
boolean result;
if(this.jourDeLaSemaine ==j1.jourDeLaSemaine){
result;

// m�thode(s) d'instance s'il y a lieu
public boolean equals (Journee j2){
boolean result;
if(this.jourDeLaSemaine ==j2.jourDeLaSemaine){

} // Journee



thanks
19 years ago
Hi, I tried to wirte down my Day class, but I'm all confuse !!!

this is what I wrote , I'm getting all kinds of error when I'm compiling(beside the fact that the class is not complete !!)

If anybody can help me on this one, I'd really appreciate.
(once again, sorry if the code is in french, my java course is in french !!)




public class Journee {

// variable(s) de classe s'il y a lieu
private String lundi = "lu";
private String mardi = "ma";
private String mercredi = "me";
private String jeudi = "ju";
private String vendredi = "ve";
private String samedi = "sa";
private String dimanche = "di";

// variable(s) d'instance s'il y a lieu
String jourSemaine;

// constructeur(s) s'il y a lieu
public journee(String joursemaine){
lundi = new string(joursemaine);
mardi = new String (joursemaine);
mercredi = new String (joursemaine);
jeudi = new String (joursemaine);
vendredi = new String (joursemaine);
samedi = new String (joursemaine);
dimanche = new String (joursemaine);

}


// m�thode(s) de classe s'il y a lieu

// m�thode(s) d'instance s'il y a lieu
public String getSequence(){
return new String("lu");
}
public void setSequenece(Stringjoursemaine){
"lu"= new String(joursemaine);
}
public String getSequence(){
return new String("ma");
}
public void setSequenece(Stringjoursemaine){
"ma"= new String(joursemaine);
}
public String getSequence(){
return new String("me");
}
public void setSequenece(Stringjoursemaine){
"me"= new String(joursemaine);
}
public String getSequence(){
return new String("ju");
}
public void setSequenece(Stringjoursemaine){
"ju"= new String(joursemaine);
}
public String getSequence(){
return new String("ve");
}
public void setSequenece(Stringjoursemaine){
"ve"= new String(joursemaine);
}
public String getSequence(){
return new String("sa");
}
public void setSequenece(Stringjoursemaine){
"sa"= new String(joursemaine);
}
public String getSequence(){
return new String("di");
}
public void setSequenece(Stringjoursemaine){
"di"= new String(joursemaine);
}

public boolean equals(Sequence j1){
boolean result
if(this.lundi ==j1.lundi){
result = this.

} // Journee
19 years ago
After creating the program (everything in the same class) now I need to separate by program in 3 classes.

I need to create 4 class for the whole project.
One class that is called Facture (Billing), one that is call Journee(Days)
another one called Billet (Tickets) and the last one which is the main one.

At the moment I tried to figure it out writing pseudo-codes, but I'm not really sure about the coding.

As for an Example, here's my Days class (in pseudo-code)
(it's in both french an english since my Java class is in French)
---------------------

Attributes of class
the constants which describe the values allowed for the day of the Attributs week


Attibutes

String jourDeLaSemaine// LU=lundi, MA=mardi... DI=dimanche


Constructeur

Journee()


M�thodes of authority

boolean estFinDeSemaine()
Makes it possible to check the day of the week seized is one day of the weekend. Turn over true if the day of the week is SA or DI. False if not.


Methods of class (static)

boolean estJourneeValide () Makes it possible to validate the day of the week at the time of the seizure. Turn over true if the day of the week is valid (LU, MA, ME, I, VE, SA, DI). False if not.


Since I'm referring to my first code (will be at the bottom of this post)
I'm trying to say in the Journee Class

Attributes of the class
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";

Attributes

public String jourSemaine;

Constructeur

jourSemaine = New journee();

And then I need to validate the day of the week using True or false
should I use the "compareTo" so it can validate ??

--
Here's my code (all in french) (the one that contains everything but now I need to separate them in 4 classes)

Can youl tell what I'm doing wrong but more how can I organize all this so I can make something logical.

Thanks
Eddy

public class Facturation {

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

public static void main (String[] params) {
// Bloc de D�claration
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;
final double tauxTps = 0.07;
final double tauxTvq = 0.075;
final byte txTps = 7;
final double txTvq = 7.5;
String encoreUnClientATraiter;
String jourSemaine;
double PrixUnitaireEnfant = 0;
double PrixUnitaireEtudiant = 0;
double PrixUnitaireAdulte = 0;
double PrixUnitaireFamille = 0;
double PrixUnitaireAgeDor = 0;
double nbBilletTotalBilletParJour = 0;
int nbBilletFamille = 0;
int nbBilletEnfant = 0;
int nbBilletEtudiant = 0;
int nbBilletAdulte = 0;
int nbBilletAgeDor = 0;
double montantBilletEnfant = 0;
double montantBilletEtudiant = 0;
double montantBilletAdulte = 0;
double montantBilletFamille = 0;
double montantBilletAgeDor = 0;
double montantTotalBillet = 0;
double montantTPS = 0;
double montantTVQ = 0;
double montantTotalFacture = 0;

// D�but de l'algorithme

do // pour chaque client
// Bloc de saisie
//jour de la semaine
{

System.out.println("***** ENTRER LES DONN�ES SUIVANTE EN MINUSCULES *****");
System.out.print("Entrez le jour de la visite :" + " ");
System.out.print("lu=Lundi, ma=Mardi, me=Mercredi, ju=Jeudi, ve=Vendredi, sa=Samedi ou di=Dimanche :");
jourSemaine = Clavier.lireString();
System.out.println();
//Nombre de Billets pour chaque groupe d'�ge
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 laissez-passer famille:");
nbBilletFamille = Clavier.lireInt();
System.out.print("Entre le nombre de billets pour les Ainees (65 ans et plus):");
nbBilletAgeDor = Clavier.lireInt();
// BLOC DE CALCUL
// D�terminer le prix unitaire des billets (selon le jour de la semaine)
if (lundi.equals(jourSemaine)){ //Bloc pour le Lundi
PrixUnitaireEnfant = prixUnitaireEnfantSemaine;
PrixUnitaireEtudiant = prixUnitaireEtudiantSemaine;
PrixUnitaireAdulte = prixUnitaireAdulteSemaine;
PrixUnitaireFamille = prixUnitaireFamilleSemaine;
PrixUnitaireAgeDor = prixUnitaireAgeDorSemaine;
System.out.println();
System.out.print ("Vous avez entr� Lundi" + " et ");
}
else if (mardi.equals(jourSemaine)){ //Bloc pour le Mardi
PrixUnitaireEnfant = prixUnitaireEnfantSemaine;
PrixUnitaireEtudiant = prixUnitaireEtudiantSemaine;
PrixUnitaireAdulte = prixUnitaireAdulteSemaine;
PrixUnitaireFamille = prixUnitaireFamilleSemaine;
PrixUnitaireAgeDor = prixUnitaireAgeDorSemaine;
System.out.println();
System.out.print ("Vous avez entr� Mardi" + " et ");
}
else if (mercredi.equals(jourSemaine)){ //Bloc pour le Mercredi
PrixUnitaireEnfant = prixUnitaireEnfantSemaine;
PrixUnitaireEtudiant = prixUnitaireEtudiantSemaine;
PrixUnitaireAdulte = prixUnitaireAdulteSemaine;
PrixUnitaireFamille = prixUnitaireFamilleSemaine;
PrixUnitaireAgeDor = prixUnitaireAgeDorSemaine;
System.out.println();
System.out.print ("Vous avez entr� Mercredi" + " et ");
}
else if (jeudi.equals(jourSemaine)){ //Bloc pour le Jeudi
PrixUnitaireEnfant = prixUnitaireEnfantSemaine;
PrixUnitaireEtudiant = prixUnitaireEtudiantSemaine;
PrixUnitaireAdulte = prixUnitaireAdulteSemaine;
PrixUnitaireFamille = prixUnitaireFamilleSemaine;
PrixUnitaireAgeDor = prixUnitaireAgeDorSemaine;
System.out.println();
System.out.print ("Vous avez entr� Jeudi" + " et ");
}
else if (vendredi.equals(jourSemaine)){ //Bloc pour le Vendredi
PrixUnitaireEnfant = prixUnitaireEnfantSemaine;
PrixUnitaireEtudiant = prixUnitaireEtudiantSemaine;
PrixUnitaireAdulte = prixUnitaireAdulteSemaine;
PrixUnitaireFamille = prixUnitaireFamilleSemaine;
PrixUnitaireAgeDor = prixUnitaireAgeDorSemaine;
System.out.println();
System.out.print ("Vous avez entr� Vendredi" + " et ");
}
else { //Bloc pour le Samedi et Dimanche
PrixUnitaireEnfant = prixUnitaireEnfantFinSemaine;
PrixUnitaireEtudiant = prixUnitaireEtudiantFinSemaine;
PrixUnitaireAdulte = prixUnitaireAdulteFinSemaine;
PrixUnitaireFamille = prixUnitaireFamilleFinSemaine;
PrixUnitaireAgeDor = prixUnitaireAgeDorFinSemaine;
System.out.println();
System.out.print ("Vous avez choisit une journ�e durant la fin de semaine" + " et ");
}
//calculer le montant des billets pour chaque groupe d'age
// Les calcules sont effectu�s selon la journ�e de la semaine entr�e
montantBilletEnfant = PrixUnitaireEnfant * nbBilletEnfant;
montantBilletEtudiant = PrixUnitaireEtudiant * nbBilletEtudiant;
montantBilletAdulte = PrixUnitaireAdulte * nbBilletAdulte;
montantBilletFamille = PrixUnitaireFamille * nbBilletFamille;
montantBilletAgeDor = PrixUnitaireAgeDor * nbBilletAgeDor;

// calculer le montant total des billets
// Il s'agit de la somme de tous les montants m�me ceux avec des 0
montantTotalBillet = montantBilletEnfant + montantBilletEtudiant + montantBilletAdulte + montantBilletFamille + montantBilletAgeDor;


// calculer le montant des taxes
montantTPS = montantTotalBillet * tauxTps;
montantTVQ = (montantTotalBillet + montantTPS) * tauxTvq; // Le montant de la TVQ est ajout� au total du montant total multiplier par la TPS
// calculer le montant total de la facture
montantTotalFacture = montantTotalBillet + montantTPS + montantTVQ;
// calculer le nombre de billets vendus par jour
nbBilletTotalBilletParJour = nbBilletTotalBilletParJour + nbBilletEnfant + nbBilletEtudiant + nbBilletAdulte + nbBilletFamille + nbBilletAgeDor;

// ajout de la date systeme dans le bloc d'affichage

// BLOC D'AFFICHAGE

// Afficher la date
NumberFormat formatMonetaire = NumberFormat.getCurrencyInstance(); // format mon�taire
SimpleDateFormat formatDate = new SimpleDateFormat("dd-MM-yyyy"); // format de date
Date dateSysteme = new Date(); // Cr�ation d'un objet date
// La date du syst�me
System.out.print("Nous sommes le:" + " ");
System.out.println(formatDate.format(dateSysteme));
System.out.println();
// voici le prix unitaire et le nombre de billets pour le groupe enfant
System.out.print("Vous avez achet� :" + " " + nbBilletEnfant + " " );
System.out.println(" " + "billets pour les enfants de 10 ans et moins");
System.out.print("le prix unitaire est:");
System.out.println(formatMonetaire.format(PrixUnitaireEnfant));
System.out.println();
// le prix unitaire et le nombre de billets pour le groupe �TUDIANT
System.out.print("Vous avez achet�:" + " " + nbBilletEtudiant + " " );
System.out.println(" " + "billets pour les etudiants de 11 � 17");
System.out.print("le prix unitaire est:" );
System.out.println(formatMonetaire.format(PrixUnitaireEtudiant));
System.out.println();
//le prix unitaire et le nombre de billets pour le groupe ADULTE
System.out.print("Vous avez achet�:" + " " + nbBilletAdulte + " " );
System.out.println(" " + "billets pour les adultes de moins de 65 ans");
System.out.print("le prix unitaire est:");
System.out.println(formatMonetaire.format(PrixUnitaireAdulte));
System.out.println();
// le prix unitaire et le nombre de billets pour le groupe FAMILLE
System.out.print("Vous avez achet�:" + " " + nbBilletFamille + " " );
System.out.println(" " + "billets pour un laissez-passer familliale");
System.out.print("le prix unitaire est:");
System.out.println(formatMonetaire.format(PrixUnitaireFamille));
System.out.println();
//le prix unitaire et le nombre de billets pour le groupe age d'or
System.out.print("Vous avez achet�:" + " " + nbBilletAgeDor + " " );
System.out.println(" " + "billets pour les ainees de 65 ans et plus");
System.out.print("le prix unitaire est:");
System.out.println(formatMonetaire.format(PrixUnitaireAgeDor));
System.out.println();
//C'etait la zone d'affichage pour les billets
// Voici le total des billets
System.out.print("Le montant des billets avant taxes est de :");
System.out.println(formatMonetaire.format(montantTotalBillet));
//Le montant avec les taxes TPS en premier
System.out.print("le taux pour la tps est�:" + txTps +"%" + " ");
System.out.print(" " + "Le montant de la tps est :");
System.out.println(formatMonetaire.format(montantTPS));
// TVQ en second
System.out.print("le taux pour la tpq est�:" + txTvq + "%" + " ");
System.out.print(" " + "le montant de la tvq est :");
System.out.println(formatMonetaire.format(montantTVQ));
//Le montant de la pr�sente facture
System.out.print("le montant total de la facture :");
System.out.println(formatMonetaire.format(montantTotalFacture));
// Il faut le meme traitement plusieurs fois
// Avant de demander � l'utilisateur du programme s'il y a d'autres clients � traiter
System.out.print("Amusez-vous et passer une excellente journ�e." + " ");
System.out.println("Pr�sentez la facture et obtenez 10% de rabais � la boutique souvenir");
System.out.println();
System.out.println("***** NOTE: LA PROCHAINE ENTR�E DOIT �TRE ENTR� EN MINUSCULES *****");
// Maintenant nous demandons s'il y a un autre client � traiter
System.out.println("Est-ce qu'il y a un autre client a traiter : (oui ou non):");
encoreUnClientATraiter = Clavier.lireString();
} while (!encoreUnClientATraiter.equals("non"));
System.out.println("Il n'y a plus de nouveau clients");
System.out.println("Pour repartir le programme, fermer la fen�tre et �x�cuter � nouveau le programme de facturation");

// fin de l'algorithme

} // main

} // Facturation
19 years ago
Forgot about my last question.
After playing with it a couple time everything is fine.

Thanks for all your help
19 years ago
Thanks,
I will try this.
I taught there would be a "small" command where we can specify the the number of decimals. Just like in SQL we can say something like round(...*100,2) where 2 represents the number of decimals

I will try with the formatter class, I also taught that maybe I can use the a "casting" to conver the value.
I tried a few things already but it didn't work.
19 years ago
Thanks again, after making the modification, it's working just fine.

I also added the code so we can get the system date and a $ symbol and both of them are working well.

On another point
I was playing with the decimals stuff but I'm not getting what I need.
I want to specify Only 2 decimals.
What could be the easiest way to write this one down

Thanks
Ed
19 years ago
thanks again

this works just fine now,
I had to correct a few thinks in my calculation because I was getting a really bad result !!! But now this is fine.

I have anohter question.
Since I'm using the DO - While instruction

In my program I'm trying to say Do (the whole calculation) while the answer is "oui" (which is Yes).

Regardless of what I'm typing, either oui or non
It's looping over and over.

Only once when I entered Non it stopped, but I've testing it more than 30 times and it's always looping.

DO you have any suggestion

Thanks
Ed
19 years ago
Hello to All,

I'm having a little issue while runnig the program.
Here's the explanation and the code is at the bottom ...
(I'm sorry the whole program is in french since my Java class is in French !!)

In the program the first question is "Which Day"

There is two different prices for both Weekdays and Weekends.
I'm using an IF, ELSE IF, ELSE... structure.
basically I entered If (jourSemaine == "LU){ ...

(FYI JourSemain which means weekday and LU stands for Lundi which is Monday)

The issue that I'm having is ; regardlees of the day that is enter, it looks like the program skip the appropriate instructions and go directly to the ELSE instruction, which is ok for the weekends but returns wrong values for Weekdays (LU, MA, ME, JE, VE)
as for an example, for an Adulte (Adult) the price during the week is 26$ but the program will return 29$ which is the price on the weekend.

I Also have another issue which is the Loop using a DO - While, at the end there is question that says "encore un autre traitement" which means "is there an other customer ..." the answer is by "yes or no" regardless of what I'm typing it will loop again and again.

I would really appreciate if you can help on this one
let me know what is wrong in my program !!!
Thanks in adavce
Ed

---
Here's the program

public class facturation {

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

public static void main (String[] params) {
// Bloc de D�claration
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;
final double tauxTps = 0.07;
final double tauxTvq = 0.075;
String encoreUnClientATraiter = "oui";
String jourSemaine;
double PrixUnitaireEnfant = 0.00;
double PrixUnitaireEtudiant = 0.00;
double PrixUnitaireAdulte = 0.00;
double PrixUnitaireFamille = 0.00;
double PrixUnitaireAgeDor = 0.00;
double nbBilletTotalBilletParJour = 0.00;
int nbBilletFamille = 0;
int nbBilletEnfant = 0;
int nbBilletEtudiant = 0;
int nbBilletAdulte = 0;
int nbBilletAgeDor = 0;
double montantBilletEnfant = 0.00;
double montantBilletEtudiant = 0.00;
double montantBilletAdulte = 0.00;
double montantBilletFamille = 0.00;
double montantBilletAgeDor = 0.00;
double montantTotalBillet = 0.00;
double montantTPS = 0.00;
double montantTVQ = 0.00;
double montantTotalFacture = 0.00;

// D�but de l'algorithme
do // pour chaque client
// Bloc de saisie
//jour de la semaine
{
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();
// BLOC DE CALCUL
// D�terminer le prix unitaire des billets (selon le jour de la semaine)
if (jourSemaine == "LU"){
PrixUnitaireEnfant = prixUnitaireEnfantSemaine;
PrixUnitaireEtudiant = prixUnitaireEtudiantSemaine;
PrixUnitaireAdulte = prixUnitaireAdulteSemaine;
PrixUnitaireFamille = prixUnitaireFamilleSemaine;
PrixUnitaireAgeDor = prixUnitaireAgeDorSemaine;
}
else if (jourSemaine == "MA"){
PrixUnitaireEnfant = prixUnitaireEnfantSemaine;
PrixUnitaireEtudiant = prixUnitaireEtudiantSemaine;
PrixUnitaireAdulte = prixUnitaireAdulteSemaine;
PrixUnitaireFamille = prixUnitaireFamilleSemaine;
PrixUnitaireAgeDor = prixUnitaireAgeDorSemaine;
}
else if (jourSemaine == "ME"){
PrixUnitaireEnfant = prixUnitaireEnfantSemaine;
PrixUnitaireEtudiant = prixUnitaireEtudiantSemaine;
PrixUnitaireAdulte = prixUnitaireAdulteSemaine;
PrixUnitaireFamille = prixUnitaireFamilleSemaine;
PrixUnitaireAgeDor = prixUnitaireAgeDorSemaine;
}
else if (jourSemaine == "JU"){
PrixUnitaireEnfant = prixUnitaireEnfantSemaine;
PrixUnitaireEtudiant = prixUnitaireEtudiantSemaine;
PrixUnitaireAdulte = prixUnitaireAdulteSemaine;
PrixUnitaireFamille = prixUnitaireFamilleSemaine;
PrixUnitaireAgeDor = prixUnitaireAgeDorSemaine;
}
else if (jourSemaine == "VE"){
PrixUnitaireEnfant = prixUnitaireEnfantSemaine;
PrixUnitaireEtudiant = prixUnitaireEtudiantSemaine;
PrixUnitaireAdulte = prixUnitaireAdulteSemaine;
PrixUnitaireFamille = prixUnitaireFamilleSemaine;
PrixUnitaireAgeDor = prixUnitaireAgeDorSemaine;
}
else {
PrixUnitaireEnfant = prixUnitaireEnfantFinSemaine;
PrixUnitaireEtudiant = prixUnitaireEtudiantFinSemaine;
PrixUnitaireAdulte = prixUnitaireAdulteFinSemaine;
PrixUnitaireFamille = prixUnitaireFamilleFinSemaine;
PrixUnitaireAgeDor = prixUnitaireAgeDorFinSemaine;
}
//calculer le montant des billets pour chaque groupe d'age
montantBilletEnfant = PrixUnitaireEnfant * nbBilletEnfant;
montantBilletEtudiant = PrixUnitaireEtudiant * nbBilletEtudiant;
montantBilletAdulte = PrixUnitaireAdulte * PrixUnitaireAdulte;
montantBilletFamille = PrixUnitaireFamille * nbBilletFamille;
montantBilletAgeDor = PrixUnitaireAgeDor * PrixUnitaireAgeDor;
// calculer le montant total des billets
montantTotalBillet = montantBilletEnfant + montantBilletEtudiant + montantBilletAdulte + montantBilletFamille + montantBilletAgeDor;
// calculer le montant des taxes
montantTPS = montantTotalBillet * tauxTps;
montantTVQ = (montantTotalBillet + montantTPS) * tauxTvq;
// calculer le montant total de la facture
montantTotalFacture = montantTotalBillet + montantTPS + montantTVQ;
// calculer le nombre de billets vendus par jour
nbBilletTotalBilletParJour = nbBilletTotalBilletParJour + nbBilletEnfant + nbBilletEtudiant + nbBilletAdulte + nbBilletFamille + nbBilletAgeDor;
// ajout de la date systeme

// BLOC D'AFFICHAGE

// Afficher la date
System.out.print("Nous sommes le:");

// voici le prix unitaire et le nombre de billets pour le groupe enfant
System.out.print("Vous avez achet�:" + nbBilletEnfant );
System.out.print("billets pour les enfants de 10 ans et moins");
System.out.print("le prix unitaire est:" + PrixUnitaireEnfant);
System.out.println();
// le prix unitaire et le nombre de billets pour le groupe ETUDIANT
System.out.print("Vous avez achet�:" + nbBilletEtudiant );
System.out.print("billets pour les etudiants de 11 � 17");
System.out.print("le prix unitaire est:" + PrixUnitaireEtudiant);
System.out.println();
//le prix unitaire et le nombre de billets pour le groupe ADULTE
System.out.print("Vous avez achet�:" + nbBilletAdulte );
System.out.print("billets pour les adultes de moins de 65 ans");
System.out.print("le prix unitaire est:" + PrixUnitaireAdulte);
System.out.println();
// le prix unitaire et le nombre de billets pour le groupe FAMILLE
System.out.print("Vous avez achet�:" + nbBilletFamille );
System.out.print("billets pour un laissez-passer familliale");
System.out.print("le prix unitaire est:" + PrixUnitaireFamille);
System.out.println();
//le prix unitaire et le nombre de billets pour le groupe age d'or
System.out.print("Vous avez achet�:" + nbBilletAgeDor );
System.out.print("billets pour les ainees de 65 ans et plus");
System.out.print("le prix unitaire est:" + PrixUnitaireAgeDor);
System.out.println();
//C'etait la zone d'affichage pour les billets
// Voici le total des billets
System.out.print("Le montant des billets avant taxes est de :" + montantTotalBillet);
//Le montant avec les taxes TPS en premier
System.out.print("le taux pour la tps est :" + tauxTps);
System.out.print("Le montant de la tps est :" + montantTPS);
// TVQ en second
System.out.print("le taux pour la tpq est :" + tauxTvq);
System.out.print("le montant de la tvq est :" + montantTVQ);
//Le montant de la pr�sente facture
System.out.print("le montant total de la facture :" + montantTotalFacture);
// Il faut le meme traitement plusieurs fois
// Demander � l'utilisateur du programme s'il y a d'autres clients � traiter
System.out.print("Est-ce qu'il y a un autre client a traiter : (Oui ou Non):");
encoreUnClientATraiter = Clavier.lireString();
} while (encoreUnClientATraiter != "Non");

} // main

} // facturation
19 years ago
Thanks for all your help,
it's working fine,

now I'm trying to finish my coding.

thanks again

Eddy
19 years ago
Thanks everyone for your replies,
I will test everything as soons as I have a chance.
19 years ago
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
19 years ago