out.println("<h1>Facture Achat</h1>");
out.println("<table border='1'>");
out.println("<tr>");
out.println("<th>N° Achat</th>");
out.println("<th>Nom Produit</th>");
out.println("<th>Prix Achat</th>");
out.println("<th>Quantite Achat</th>");
out.println("<th>TVA %</th>");
out.println("<th>Montant</th>");
out.println("</tr>");
out.println("<tr>");
out.println("<td> " + request.getParameter("num_achat")+"</td>");
out.println("<td>"+request.getParameter("nom_Article")+"</td>");
out.println("<td>"+request.getParameter("prix")+"</td>");
out.println("<td>"+request.getParameter("quantite")+"</td>");
out.println("<td>"+request.getParameter("tva")+"</td>");
out.println("<td>"+Montant+"</td>");
out.println("</tr>");
out.println("</table>");
int numAchat = Integer.parseInt(request.getParameter("num_achat"));
String nomArticle = request.getParameter("nom_Article");
int prix = Integer.parseInt(request.getParameter("prix"));
int quantite = Integer.parseInt(request.getParameter("quantite"));
double tva = Double.parseDouble(request.getParameter("tva").replace("%", ""));
double Montant=(prix*quantite)*(1+tva/100);
<form action='Achatservlet' methode='post'>
<label for='num_achat'>N achat :</label>
<input type='number' id='Nachat' name='num_achat' required>
<br><br>
<label for='nom_Article'>Nom Produit :</label>
<input type='text' id='nomproduit' name='nom_Article' required>
<br><br>
<label for='prix'>Prix Produit :</label>
<input type='number' id='prixproduit' name='prix' required>
<br><br>
<label for='quantite'>Quantite :</label>
<input type='number' id='quantite' name='quantite' required>
<br><br>
<label for="tva">TVA </label>
<input type="radio" name="tva" value="5%" checked />5%
<input type="radio" name="tva" value="15%">15%
<input type="radio" name="tva" value="15%">20%
<br><br>
<label for="taux_remise">Taux de Remise (en %) :</label>
<select id="taux_remise" name="taux_remise">
<option value="0">0</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
</select>
<br><br>
<input type="submit" value="Calcul">
<input type="reset" value="Vider"
</form>
public double conversion_devise() {
switch(devise) {
case "Euro":
return conversion = (double) (montant / 0.094);
case "Dollar":
return conversion=(double)(montant / 0.111);
case "Livre Sterling":
return conversion=(double)(montant / 0.080);
default:
System.out.println("Devise non prise en charge.");
return -1; // Valeur indiquant une devise non prise en charge
}
}
public double conversion_devise(){
double convertedAmount = montant;
if (devise.equals("Euro"))
convertedAmount *= 0.094;
else if (devise.equals("Dollar"))
convertedAmount *= 0.111;
else if (devise.equals("Livre Sterling"))
convertedAmount *= 0.080;
return convertedAmount;
}
<jsp:useBean id="obj" class="metier.Devise" scope="session"/>
<jsp:setProperty name="obj" property="montant"/>
<%
// Set devise property using request parameter
obj.setDevise(request.getParameter("devise"));
%>
<p>Le montant <%= obj.getMontant() %> DHS converti est <%= obj.conversion_devise() %></p>
<jsp:useBean id="obj" class="metier.Occ" scope="session"/>
<jsp:setProperty name="obj" property="*"/>
<p>le nombre <jsp:getProperty name="obj" property="nombre"/> apparait <jsp:getProperty name="obj" property="nbreOccurence" /> fois <p>
<jsp:useBean id="obj" class="metier.Devise" scope="session"/>
<jsp:setProperty name="obj" property="*"/>
<%
// Appeler la m thode conversion_devise() pour effectuer la conversion
obj.conversion_devise();
%>
<p><jsp:getProperty name="obj" property="montant"/> DHS en <jsp:getProperty name="obj" property="devise"/> vaut <%= obj.getConversion() %></p>
| |