Anzzhhela98

dd

Jul 14th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Кино_ваучер
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int countMovies = int.Parse(Console.ReadLine());
  10.  
  11.             double  maxRating =double.MinValue;
  12.             string maxMovie = "";
  13.  
  14.             double minRating = double.MaxValue;
  15.             string minMovie = "";
  16.  
  17.             double sum = 0;
  18.             for (int i = 0; i < countMovies; i++)
  19.             {
  20.                 string nameMovie = Console.ReadLine();
  21.                 double rating = double.Parse(Console.ReadLine());
  22.                 if (rating>maxRating)
  23.                 {
  24.                     maxRating = rating;
  25.                     maxMovie = nameMovie;
  26.                 }
  27.                 if (rating < minRating)
  28.                 {
  29.                    minRating = rating;
  30.                     minMovie = nameMovie;
  31.                 }
  32.                 sum += rating;
  33.             }
  34.             double average = sum / countMovies;
  35.             Console.WriteLine($"{maxMovie} is with highest rating: {maxRating}");
  36.             Console.WriteLine($"{minMovie:f2} is with lowest rating: {minRating}");
  37.             Console.WriteLine($"Average rating: {average:f1}");
  38.         }
  39.     }
  40. }
Add Comment
Please, Sign In to add comment