Hi everybody, I need some help with my first Java program. My teacher don't teach really good ... I have a problem to solve in my script. At that time all are okay but all number must be rounding to 2 decimal :S
That's all my Java program (He is in french but if you need some explain ask me)
/**
* @(#)billetski.java
*
*
* @author
* @version 1.00 2009/10/5
*/
import javax.swing.JOptionPane; // requise pour les fenêtres de lectures-écritures
public class billetski {
/**
* Creates a new instance of <code>billetski</code>.
*/
public billetski() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//constantes
double PUBLICITE = 0.18;
double ENTRETIEN = 0.26;
double PROFIT = 0.14;
double TAXELOISIR = 3;
double TPS = 0.05;
double TVQ = 0.075;
//variables
double coutBase;
double montantTotal;
double montantTPS;
double montantTVQ;
double montantPublicite;
double montantEntretien;
double montantProfit;
double pourcCoutBase;
double pourcTPS;
double pourcTVQ;
double pourcPub;
double pourcEntretien;
double pourcTaxeLoisir;
double pourcProfit;
//But du programme
JOptionPane.showMessageDialog(
null, "Ce programme permet de calculer le coût de chaque parti du coût total d'un billet de ski.","But du programme",JOptionPane.INFORMATION_MESSAGE);
coutBase = Integer.parseInt(
JOptionPane.showInputDialog("Entrer le coût de base du billet."));
montantPublicite = (coutBase*PUBLICITE);
montantEntretien = (coutBase*ENTRETIEN);
montantProfit =(coutBase*PROFIT);
montantTPS = (coutBase*TPS);
montantTVQ = (montantTPS*TVQ);
montantTotal = ((coutBase+ montantPublicite + montantProfit + montantEntretien) + montantTPS + montantTVQ + TAXELOISIR);
pourcCoutBase = ((coutBase/montantTotal)*100);
pourcEntretien = ((montantEntretien/montantTotal)*100);
pourcProfit = ((montantProfit/montantTotal)*100);
pourcPub = ((montantPublicite/montantTotal)*100);
pourcTaxeLoisir = ((TAXELOISIR/montantTotal)*100);
pourcTPS = ((montantTPS/montantTotal)*100);
pourcTVQ = ((montantTVQ/montantTotal)*100);
JOptionPane.showMessageDialog(
null, "Cout de base: " + coutBase + " " + pourcCoutBase + " %" +
"\nPublicité: " + montantPublicite + " " + pourcPub + " %" +
"\nEntretien: " + montantEntretien + " " + pourcEntretien + " %" +
"\nProfit: " + montantProfit + " " + pourcProfit + " %" +
"\nTPS: " + montantTPS + " " + pourcTPS + " %" +
"\nTVQ: " + montantTVQ + " " + pourcTVQ + " %" +
"\nTaxe Loisir " + TAXELOISIR + " " + pourcTaxeLoisir + " %" +
"\n" +
"\nMontant Total: " + montantTotal, "Coût du billet",JOptionPane.INFORMATION_MESSAGE );
}
}