Advertisement
Guest User

Untitled

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