IvetValcheva

08. Tennis Ranklist

Oct 9th, 2022
207
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 ConsoleApp3
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             double firstPonts= double.Parse(Console.ReadLine());
  11.             double points = 0;
  12.             int wonCount = 0;
  13.  
  14.             for (int i = 1; i <=n; i++)
  15.             {
  16.                 string stage =Console.ReadLine();
  17.  
  18.                 if (stage=="W")
  19.                 {
  20.                     points +=2000;
  21.                     wonCount+=1;
  22.                 }
  23.                 else if (stage == "F")
  24.                 {
  25.                     points +=1200;
  26.                 }
  27.                 else
  28.                 {
  29.                     points +=720;
  30.                 }
  31.             }
  32.  
  33.             double averagePoints = (double)points / n;
  34.             double wonPercentage = ((double)wonCount/n) * 100;
  35.  
  36.             Console.WriteLine($"Final points: {points+firstPonts}");
  37.             Console.WriteLine($"Average points: {Math.Floor(averagePoints)}");
  38.             Console.WriteLine($"{wonPercentage:F2}%");
  39.         }
  40.     }
  41. }
Add Comment
Please, Sign In to add comment