Advertisement
svephoto

Easter Competition

Nov 16th, 2019
1,338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. using System;
  2.  
  3. namespace EasterCompetition
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int numberOfCozunak = int.Parse(Console.ReadLine());
  10. string gradeAsString = string.Empty;
  11. string topShef = string.Empty;
  12.  
  13. int maxChefGrades = int.MinValue;
  14.  
  15. for (int i = 1; i <= numberOfCozunak; i++)
  16. {
  17. string nameOfChef = Console.ReadLine();
  18. gradeAsString = Console.ReadLine();
  19. int sumGrades = 0;
  20.  
  21. while (gradeAsString != "Stop")
  22. {
  23. int grade = int.Parse(gradeAsString);
  24.  
  25. if (grade <= 0 || grade > 10)
  26. {
  27. gradeAsString = Console.ReadLine();
  28. continue;
  29. }
  30.  
  31. sumGrades += grade;
  32. gradeAsString = Console.ReadLine();
  33. }
  34.  
  35. Console.WriteLine($"{nameOfChef} has {sumGrades} points.");
  36.  
  37. if (sumGrades > maxChefGrades)
  38. {
  39. maxChefGrades = sumGrades;
  40. topShef = nameOfChef;
  41. Console.WriteLine($"{topShef} is the new number 1!");
  42. }
  43. }
  44.  
  45. Console.WriteLine($"{topShef} won competition with {maxChefGrades} points!");
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement