?php
declare(strict_types =1 );
(array)$infoclass = [
"nom" => 0,
"prenom"=> 0,
"notemath"=> 0,
"notephysique"=> 0,
"notefrancais"=> 0,
"notehistoire"=> 0,
"noteanglais"=> 0,
"moyenne"=> 0
];
(array) $ListeEleves =[
];
(int)$moyenneGeneral = 0;
(int)$moyennemath = 0;
(int)$moyenneanglais = 0;
(int)$compteurPers = 0;
(int)$meilleurnote = 0;
(int)$pirenote = 0;
(string)$prenomMeilleurNote="";
(string)$nomMeilleurNote="";
(string)$prenomPireNote="";
(string)$nomPireNote="";
(bool)$saisinote=true;
//boucle
while($saisinote):
(string)$prenom='';
(string)$nom='';
(int)$notemath=-1;
(int)$notephysique=-1;
(int)$notefrancais=-1;
(int)$notehistoire=-1;
(int)$noteanglais=-1;
(int)$moyenne = 0;
while(!$prenom):
print("Bonjour quel est le prenom de l'élève");
$prenom = trim(strval(fgets(STDIN)));
endwhile;
$infoclass["prenom"] = $prenom;
while(!$nom):
print("Bonjour quel est le nom de l'élève");
$nom = trim(strval(fgets(STDIN)));
endwhile;
$infoclass["nom"] = $nom;
while(!($notemath >=0 && $notemath <= 20)):
print("Quelle est ta note en math ? ");
$notemath = intval(trim(strval(fgets(STDIN))));
endwhile;
$infoclasse["notemath"] = $notemath;
while(!($notephysique >=0 && $notephysique <= 20)):
print("Quelle est ta note en physique ? ");
$notephysique = intval(trim(strval(fgets(STDIN))));
endwhile;
$infoclasse["notephysique"] = $notephysique;
while(!($notefrancais >=0 && $notefrancais <= 20)):
print("Quelle est ta note en francais ? ");
$notefrancais = intval(trim(strval(fgets(STDIN))));
endwhile;
$infoclasse["notefrancais"] = $notefrancais;
while(!($notehistoire >=0 && $notehistoire <= 20)):
print("Quelle est ta note en histoire ? ");
$notehistoire = intval(trim(strval(fgets(STDIN))));
endwhile;
$infoclasse["notehistoire"] = $notehistoire;
while(!($noteanglais >=0 && $noteanglais <= 20)):
print("Quelle est ta note en anglais ? ");
$noteanglais = intval(trim(strval(fgets(STDIN))));
endwhile;
$infoclasse["noteanglais"] = $noteanglais;
if($notehistoire>$meilleurnote):
$meilleurnote=$notehistoire;
$nomMeilleurNote=$infoclasse["nom"];
$prenomMeilleurNote=$infoclasse["prenom"];
endif;
if($notephysique<$pirenote):
$pirenote=$notephysique;
$nomPireNote=$infoclasse["nom"];
$prenomPireNote=$infoclasse["prenom"];
endif;
$infoclasse["moyenne"]= $notemath+ $notephysique+ $notefrancais+ $notehistoire+ $noteanglais;
$infoclasse["moyenne"]=$infoclasse["moyenne"]/5;
$moyennemath= $moyennemath +$infoclasse["notemath"];
$moyenneanglais= $moyenneanglais +$infoclasse["noteanglais"];
$moyenne=$infoclasse["moyenne"];
$moyenneGeneral=$moyenneGeneral+$moyenne;
printf("L'eleve a %d de moyenne".PHP_EOL ,$moyenne);
(string) $choixFin = '';
while ( $choixFin != 'y' && $choixFin != 'n'):
print('Avez vous un autre élève à entrer (y / n) ?');
$choixFin = trim(strval(fgets(STDIN)));
endwhile;
if ($choixFin == 'n') {
$saisienote = true;
} else {
$saisienote = false;
}
$ListeEleves[]= $infoclasse;
$compteurPers=$compteurPers+1;
endwhile;
print(PHP_EOL . 'Affichage Tableau des eleves' . PHP_EOL);
print_r($ListeEleves);
$moyenneGeneral=$moyenneGeneral/$compteurPers;
$moyenneanglais=$moyenneanglais/$compteurPers;
$moyennemath=$moyennemath/$compteurPers;
print(PHP_EOL . 'Résultat' . PHP_EOL);
printf(PHP_EOL . "la moyennne general est de %d sur 20".PHP_EOL,$moyenneGeneral);
printf(PHP_EOL . "la moyenne de la classe en math est de %d sur 20".PHP_EOL, $moyennemath);
printf(PHP_EOL . "la moyenne de la classe en anglais est de %d sur 20".PHP_EOL, $moyenneanglais);
print(PHP_EOL . ' OSCAR DE LA MEILLEUR NOTE ' . PHP_EOL);
printf(PHP_EOL . "le meilleur en histoire est attribué a %s %s avec %d sur 20".PHP_EOL,$prenomMeilleurNote,$nomMeilleurNote,$meilleurnote);
print(PHP_EOL . ' OSCAR DE LA PIRE NOTE ' . PHP_EOL);
printf(PHP_EOL . "la pire note en physique est attribué a %s %s avec %d sur 20".PHP_EOL,$prenomPireNote,$nomPireNote,$pirenote);