Advertisement
silvana1303

tennis ranklist

Apr 27th, 2020
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.53 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Loops
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int tournaments = int.Parse(Console.ReadLine());
  10.             int initialPoints = int.Parse(Console.ReadLine());
  11.             string typeTournament = Console.ReadLine();
  12.  
  13.            
  14.             int wPoints = 0;
  15.             int fPoints = 0;
  16.             int sfPoints = 0;
  17.  
  18.             int winnerCount = 0;
  19.  
  20.             for (int i = 1; i <= tournaments; i++)
  21.             {
  22.                 if (typeTournament == "W")
  23.                 {
  24.                     wPoints += 2000;
  25.                     initialPoints += 2000;    
  26.                     winnerCount++;
  27.                 }
  28.                 else if (typeTournament == "F")
  29.                 {
  30.                     fPoints += 1200;
  31.                     initialPoints += 1200;
  32.                    
  33.                 }
  34.                 else
  35.                 {
  36.                     sfPoints += 720;
  37.                     initialPoints += 720;
  38.                    
  39.                 }
  40.  
  41.                 typeTournament = Console.ReadLine();
  42.             }
  43.  
  44.             int winnerPoints = (wPoints + fPoints + sfPoints) / tournaments;
  45.             double averagePoints = winnerPoints * 1.0;
  46.             double percent = (winnerCount * 1.0 / tournaments) * 100.0;
  47.  
  48.             Console.WriteLine($"Final points: {initialPoints}");
  49.             Console.WriteLine($"Average points: {Math.Floor(averagePoints)}");
  50.             Console.WriteLine($"{percent:f2}%");
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement