VickSuna

Untitled

Mar 3rd, 2020
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Izpit_20190406_5._Movie_Ratings
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int numMovies = int.Parse(Console.ReadLine());
  10.  
  11. double currentMin = double.MaxValue;
  12. double currentMax = double.MinValue;
  13. double sumRatingMovie = 0;
  14. string movieNameMaxRating = "";
  15. string movienameMinRating = "";
  16.  
  17. for (int i = 1; i <= numMovies; i++)
  18. {
  19. string nameMovie = Console.ReadLine();
  20. double ratingMovie = double.Parse(Console.ReadLine());
  21.  
  22. if (ratingMovie > currentMax)
  23. {
  24. currentMax = ratingMovie;
  25. movieNameMaxRating = nameMovie;
  26. }
  27. if (ratingMovie < currentMin)
  28. {
  29. currentMin = ratingMovie;
  30. movienameMinRating = nameMovie;
  31. }
  32.  
  33. sumRatingMovie += ratingMovie;
  34.  
  35. }
  36.  
  37. double averageRating = sumRatingMovie / numMovies;
  38.  
  39. Console.WriteLine($"{movieNameMaxRating} is with highest rating: {currentMax}");
  40. Console.WriteLine($"{movienameMinRating} is with lowest rating: {currentMin}");
  41. Console.WriteLine($"Average rating: {averageRating:F1}");
  42.  
  43. }
  44. }
  45. }
Add Comment
Please, Sign In to add comment