Advertisement
Guest User

Untitled

a guest
Nov 24th, 2019
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05._Movie_Ratings
  4. {
  5. class Program
  6.  
  7. {
  8. static void Main(string[] args)
  9. {
  10. int numMovie = int.Parse(Console.ReadLine());
  11.  
  12. double maxRatig = Double.MinValue;
  13. string MoviewhitMaxRating = "";
  14. double minRatig = Double.MaxValue;
  15. string MoviewhitMinRating = "";
  16. double Sum = 0;
  17.  
  18. for (int i = 1; i <= numMovie; i++)
  19. {
  20. string Movie = Console.ReadLine();
  21. double Rating = double.Parse(Console.ReadLine());
  22. Sum += Rating;
  23. if (Rating > maxRatig)
  24. {
  25. maxRatig = Rating;
  26. MoviewhitMaxRating = Movie;
  27. }
  28. if (Rating < minRatig)
  29. {
  30. minRatig = Rating;
  31. MoviewhitMinRating = Movie;
  32. }
  33. }
  34. double average = Sum / numMovie;
  35. Console.WriteLine($"{MoviewhitMaxRating} is with highest rating: {maxRatig}");
  36. Console.WriteLine($"{MoviewhitMinRating} is with lowest rating: {minRatig}");
  37. Console.WriteLine($"Average rating: {average:f1}");
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement