Last active
December 12, 2015 22:09
-
-
Save valeriu/4830731 to your computer and use it in GitHub Desktop.
Kasyan, Flora - Epreuve finale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<!-- Nom de l'étudiant : Kasyan, Flora --> | |
<title>Épreuve finale - Olympiades</title> | |
<script language="JavaScript" type="text/javascript"> | |
function afficherMessages () { | |
// declaration des variables; | |
var annee = window.parseInt(document.frm.txtAnnee.value); | |
var pays = document.frm.txtPays.value; | |
var nbOr = document.frm.txtOr.value; | |
var nbArg = document.frm.txtArg.value; | |
var nbBron = document.frm.txtBr.value; | |
var message = document.frm.txtMess; | |
var totalMed; | |
var err = true; | |
var lower = pays.toLowerCase(); | |
var upper = pays.toUpperCase(); | |
// conditions années | |
if (annee == 2006 || annee == 2010){ | |
if ( ((pays == lower || pays == upper) && pays != "")){ | |
if (!isNaN(nbOr) && (parseInt(nbOr) == parseFloat(nbOr)) && | |
!isNaN(nbArg) && (parseInt(nbArg) == parseFloat(nbArg)) && | |
!isNaN(nbBron)&& (parseInt(nbBron)== parseFloat(nbBron))) { | |
err = false; | |
} else { | |
message.value = "Le champs doivent etre numerique."; | |
} | |
} else { | |
//err = true; | |
message.value = "Pays dois etre ecrit en minuscule ou majuscule."; | |
} | |
}else { | |
//err = true; | |
message.value = "Vous devez choisir l'année 2006 ou 2010 seulement."; | |
} | |
// compare nombre des medailles et affiche message | |
if (err == false) { | |
//Frist letter Upper | |
var paysUp = lower[0].toUpperCase() + lower.slice(1); | |
if (parseInt(nbOr) > parseInt(nbArg) && parseInt(nbOr) > parseInt(nbBron)){ | |
message.value = "Surtout de l\`or pour le " + paysUp ; | |
} | |
else if (parseInt(nbArg) > parseInt(nbOr) && parseInt(nbArg) > parseInt(nbBron)){ | |
message.value = "Surtout de l\`argent pour le " + paysUp ; | |
} | |
else if (parseInt(nbBron) > parseInt(nbOr) && parseInt(nbBron) > parseInt(nbArg)){ | |
message.value = "Syrtout de l\`bronze pour le " + paysUp ; | |
} else { | |
message.value = "De toutes les couleurs pour le " + paysUp ; | |
} | |
// conditions si pays Canada | |
if (lower == "canada") { | |
totalMed = window.parseInt(frm.txtOr.value) + window.parseInt(frm.txtArg.value) +window.parseInt(frm.txtBr.value); | |
if ((totalMed >= 20 && annee == 2006) || (totalMed >= 25 && annee == 2010)){ | |
window.alert("Bravo!"); | |
} else { | |
window.alert("La proshaine fois!"); | |
} | |
} | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<h1>Résultats - Kasyan, Flora</h1> | |
<form name="frm"> | |
Année (2006 ou 2010) <input type="text" size="20" name="txtAnnee" /><br /> | |
Pays <input type="text" size="20" name="txtPays" /><br /> | |
Nombre de médailles d'or <input type="text" size="10" name="txtOr" /><br /> | |
Nombre de médailles d'argent <input type="text" size="10" name="txtArg" /><br /> | |
Nombre de médailles de bronze <input type="text" size="10" name="txtBr" /><br /><br /> | |
<input type="button" value="Afficher les messages" onclick="afficherMessages()" /> | |
<input type="text" size="50" name="txtMess" /> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment