Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $n=intval(readline());
- $highest=0;
- $lowest=PHP_INT_MAX;
- $avarage=0;
- $nameLow="";
- $nameHigh="";
- for ($i=0;$i<$n;$i++){
- $movie=readline();
- $rating=floatval(readline());
- if($highest<$rating){
- $highest=$rating;
- $nameHigh=$movie;
- }
- if ($lowest>$rating){
- $lowest=$rating;
- $nameLow=$movie;
- }
- $avarage+=$rating;
- }
- $highest=number_format($highest,1,".","");
- $lowest=number_format($lowest,1,".","");
- $avarageFormatted=number_format(($avarage/$n),1,".","");
- echo "$nameHigh is with highest rating: $highest".PHP_EOL;
- echo "$nameLow is with lowest rating: $lowest".PHP_EOL;
- echo "Average rating: $avarageFormatted";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement