Guest User

Untitled

a guest
Apr 19th, 2019
369
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $n=intval(readline());
  3. $highest=0;
  4. $lowest=PHP_INT_MAX;
  5. $avarage=0;
  6. $nameLow="";
  7. $nameHigh="";
  8.  
  9. for ($i=0;$i<$n;$i++){
  10.     $movie=readline();
  11.     $rating=floatval(readline());
  12.   if($highest<$rating){
  13.       $highest=$rating;
  14.       $nameHigh=$movie;
  15.   }      
  16.   if ($lowest>$rating){
  17.       $lowest=$rating;
  18.       $nameLow=$movie;
  19.   }
  20.   $avarage+=$rating;
  21. }
  22. $highest=number_format($highest,1,".","");
  23. $lowest=number_format($lowest,1,".","");
  24. $avarageFormatted=number_format(($avarage/$n),1,".","");
  25. echo "$nameHigh is with highest rating: $highest".PHP_EOL;
  26. echo "$nameLow is with lowest rating: $lowest".PHP_EOL;
  27. echo "Average rating: $avarageFormatted";
RAW Paste Data