Javascript programmer un jeu de dés
gen
-
bg62 Messages postés 23735 Date d'inscription Statut Modérateur Dernière intervention -
bg62 Messages postés 23735 Date d'inscription Statut Modérateur Dernière intervention -
Bonjour,
je dois simuler 50 lancés de 5 dés et compter le nombre d'occurence de chacune des valeurs.. voila ce que j'ai fais ... quelqu'un peu m'aider aucun résultat s'affiche... merci d'avance
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<LINK HREF="Base.CSS" REL="stylesheet" TYPE="text/css">
<title>Tp2 IFT1144, numéro 3
</title>
</head>
<body>
<table border=0 cellspacing=0 cellpadding=10 cols=2 width="92%">
<tr>
<td width="1%">
<img border="0" src="UMlogo.gif" width="110" height="50" alt="UdeM"></a></td>
</td>
<td width="100%"><h1> ift1144, tp2 numéro 3 </h1>
</td>
</tr>
<tr>
</tr>
</table>
<table border=0 cellspacing=0 cellpadding=10 cols=4 width="100%">
<tr>
</tr>
<tr>
<td width="1%">
</td>
<td width="99%"><h2> Table de fréquence de tirage de dés </h2>
</td>
</tr>
</table>
<script>
do {
function lancerDe(max){
return Math.floor(Math.random() * 10);
}
while face1+face2+face3+face4+face5+face6==500
}
var D1, D2, D3, D4, D5
D1 = lancerDe(6);
D2 = lancerDe(6);
D3 = lancerDe(6);
D4 = lancerDe(6);
D5 = lancerDe(6);
var freq = new Array(6);
var face1=0,face2=0,face3=0,face4=0,face5=0,face6=0;
if lancerDe==1 {
face1++;
}
if lancerDe==2 {
face2++;
}
else if lancerDe==3 {
face3++;
}
else if lancerDe==4 {
face4++;
}
else if lancerDe==5 {
face5++;
}
else lancerDe==6 {
face6++;
}
</script>
<body>
<table border="1" width="50%" align="center">
<tr>
<td align="center"> Dé </td>
<td align="center"> Fréquence</td>
</tr>
<tr>
<td align="right"> 1 </td>
<td align="right"> <script>document.write(face1)</script> </ </td>
</tr>
<tr>
<td align="right"> 2 </td>
<td align="right"> <script>document.write(face2)</script> </td>
</tr>
<tr>
<td align="right"> 3 </td>
<td align="right"> <script>document.write(face3)</script> </td>
</tr>
<tr>
<td align="right"> 4 </td>
<td align="right"> <script>document.write(face4)</script> </td>
</tr>
<tr>
<td align="right"> 5 </td>
<td align="right"> <script>document.write(face5)</script> </td>
</tr>
<tr>
<td align="right"> 6 </td>
<td align="right"> <script>document.write(face6)</script> </td>
</tr>
</table>
<br>
<br><h3>Travail effectué par: Geneviève Hénault</h3>
</body>
</html>
je dois simuler 50 lancés de 5 dés et compter le nombre d'occurence de chacune des valeurs.. voila ce que j'ai fais ... quelqu'un peu m'aider aucun résultat s'affiche... merci d'avance
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<LINK HREF="Base.CSS" REL="stylesheet" TYPE="text/css">
<title>Tp2 IFT1144, numéro 3
</title>
</head>
<body>
<table border=0 cellspacing=0 cellpadding=10 cols=2 width="92%">
<tr>
<td width="1%">
<img border="0" src="UMlogo.gif" width="110" height="50" alt="UdeM"></a></td>
</td>
<td width="100%"><h1> ift1144, tp2 numéro 3 </h1>
</td>
</tr>
<tr>
</tr>
</table>
<table border=0 cellspacing=0 cellpadding=10 cols=4 width="100%">
<tr>
</tr>
<tr>
<td width="1%">
</td>
<td width="99%"><h2> Table de fréquence de tirage de dés </h2>
</td>
</tr>
</table>
<script>
do {
function lancerDe(max){
return Math.floor(Math.random() * 10);
}
while face1+face2+face3+face4+face5+face6==500
}
var D1, D2, D3, D4, D5
D1 = lancerDe(6);
D2 = lancerDe(6);
D3 = lancerDe(6);
D4 = lancerDe(6);
D5 = lancerDe(6);
var freq = new Array(6);
var face1=0,face2=0,face3=0,face4=0,face5=0,face6=0;
if lancerDe==1 {
face1++;
}
if lancerDe==2 {
face2++;
}
else if lancerDe==3 {
face3++;
}
else if lancerDe==4 {
face4++;
}
else if lancerDe==5 {
face5++;
}
else lancerDe==6 {
face6++;
}
</script>
<body>
<table border="1" width="50%" align="center">
<tr>
<td align="center"> Dé </td>
<td align="center"> Fréquence</td>
</tr>
<tr>
<td align="right"> 1 </td>
<td align="right"> <script>document.write(face1)</script> </ </td>
</tr>
<tr>
<td align="right"> 2 </td>
<td align="right"> <script>document.write(face2)</script> </td>
</tr>
<tr>
<td align="right"> 3 </td>
<td align="right"> <script>document.write(face3)</script> </td>
</tr>
<tr>
<td align="right"> 4 </td>
<td align="right"> <script>document.write(face4)</script> </td>
</tr>
<tr>
<td align="right"> 5 </td>
<td align="right"> <script>document.write(face5)</script> </td>
</tr>
<tr>
<td align="right"> 6 </td>
<td align="right"> <script>document.write(face6)</script> </td>
</tr>
</table>
<br>
<br><h3>Travail effectué par: Geneviève Hénault</h3>
</body>
</html>
A voir également:
- Javascript programmer un jeu de dés
- Programmer un sms - Guide
- 94 jeu - Télécharger - Puzzle & Réflexion
- Programmer un mail gmail - Guide
- 94 degrés jeu - Télécharger - Divers Jeux
- Jeu des logos - Télécharger - Jeux vidéo