/* * Fichier: ProduitWhile.java * Crée le: 03 décembre 2006. * Modifié: 7 juillet 2007. * Auteurs: Sébastien ESTIENNE. * SiteWeb: http://www.prog-info.org/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package chapitre4; import javax.swing.JOptionPane; /** *
Calcule le produit des entiers impairs de 1 à 15.
* @author Sébastien ESTIENNE. */ public class ProduitWhile { /** *Débute l'exécution de l'application.
* @param args Les paramètres de la ligne de commande. */ public static void main(String[] args) { // Le compteur (sentinelle). int compteur; // Le résultat du produit. int resultat = 1; // Calcule le produit des entiers impairs de 1 à 15. compteur = 1; do { resultat *= compteur; compteur += 2; } while(compteur <= 15); // Affiche le résultat du produit des entiers impairs de 1 à 15. JOptionPane.showMessageDialog(null, "Le produit des entiers impairs de 1 à 15 est : " + resultat + "."); // Termine l'application. System.exit(0); } }