Énoncé :
<SCRIPT language="JavaScript">
<!--
function calcul()
{
TPS = 0.07;
TVQ = 0.075;
var prix_article, cout_tps, cout_tvq, prix_total, tmp;
var recu, monnaie;
message = new String;
prix_article=window.prompt("Entrez le prix de l'article s.v.p. :" , "");
cout_tps = eval(parseFloat(prix_article) * TPS);
cout_tps*=100;
cout_tps = Math.round(cout_tps)/100;
cout_tvq = eval((parseFloat(cout_tps) + parseFloat(prix_article)) * TVQ);
cout_tvq*=100;
cout_tvq = Math.round(cout_tvq)/100;
prix_total = parseFloat(prix_article) + parseFloat(cout_tps) + parseFloat(cout_tvq);
prix_total*=100;
prix_total = Math.round(prix_total)/100;
message = "Prix total : " + prix_total + "$\nEntrez le montant donné par le client : ";
recu = window.prompt(message, prix_total);
monnaie = parseFloat(recu)-parseFloat(prix_total) ;
recu*=100;
recu = Math.round(recu)/100;
monnaie*=100;
monnaie = Math.round(monnaie)/100;
Window2=open("","seconde","scrollbars=no,width=500,height=250");
Window2.document.write("<HEAD><TITLE>Merci</TITLE></HEAD>")
Window2.document.write("<DL>\n"+
" <DD>Entrez le prix de l'article s.v.p. : <I>"+prix_article+"</I><BR>\n\n"+
" <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=300>\n"+
" <TR>\n <TD>Prix</TD>\n <TD> : </TD>\n <TD ALIGN=\"RIGHT\">"+prix_article+"$</TD>\n </TR>\n"+
" <TR>\n <TD>TPS</TD>\n <TD> : </TD>\n <TD ALIGN=\"RIGHT\">"+cout_tps+"$</TD>\n </TR>\n"+
" <TR>\n <TD>TVQ</TD>\n <TD> : </TD>\n <TD ALIGN=\"RIGHT\">"+cout_tvq+"$</TD>\n </TR>\n"+
" <TR>\n <TD>Prix total</TD>\n <TD> : </TD>\n <TD ALIGN=\"RIGHT\">"+prix_total+"$</TD>\n </TR>\n"+
" </TABLE>\n\n"+
" <DD><P>Entrez le montant donné par le client : <I>"+recu+"</I></P>\n\n"+
" <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=400>\n"+
" <TR>\n <TD>Montant donné</TD>\n <TD> : </TD>\n <TD ALIGN=\"RIGHT\">"+recu+"$</TD>\n </TR>\n"+
" <TR>\n <TD>Monnaie</TD>\n <TD> : </TD>\n <TD ALIGN=\"RIGHT\">"+monnaie+"$</TD>\n </TR>\n"+
" </TABLE>\n</DL>");
}
//-->
</SCRIPT>