madeofglass

Untitled

Feb 17th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05.MovieRatings
  4. {
  5.     class MovieRatings
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int numMovies = int.Parse(Console.ReadLine());
  10.  
  11.             double max = double.MinValue;
  12.             double min = double.MaxValue;
  13.  
  14.             string movieMax = "";
  15.             string movieMin = "";
  16.  
  17.  
  18.             double average = 0.0;
  19.  
  20.             for (int i = 0; i <= numMovies; i++)
  21.             {
  22.                 string movieName = Console.ReadLine();
  23.                 double rating = double.Parse(Console.ReadLine());
  24.  
  25.                 if (rating > max)
  26.                 {
  27.                     max = rating;
  28.                     movieMax = movieName;
  29.                     //Console.WriteLine(movieMax);
  30.                 }
  31.  
  32.                 if (rating < min)
  33.                 {
  34.                     min = rating;
  35.                     movieMin = movieName;
  36.                     //Console.WriteLine(movieMin);
  37.                 }
  38.  
  39.                 average += rating;
  40.                 //Console.WriteLine(average / numMovies);
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment