Advertisement
silvana1303

cruise games

May 2nd, 2020
652
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.81 KB | None | 0 0
  1. using System;
  2.  
  3. namespace exampreparation
  4. {
  5.     class exam
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string name = Console.ReadLine();
  10.             int playedGames = int.Parse(Console.ReadLine());
  11.             int volleyCount = 0;
  12.             int tennisCount = 0;
  13.             int badmintonCount = 0;
  14.             double pointsVolley = 0.0;
  15.             double pointsTennis = 0.0;
  16.             double pointsBadminton = 0.0;
  17.  
  18.             for (int i = 1; i <= playedGames; i++)
  19.             {
  20.                 string gameName = Console.ReadLine();
  21.                 int points = int.Parse(Console.ReadLine());
  22.  
  23.                 if (gameName == "volleyball")
  24.                 {
  25.                     pointsVolley += points * 1.07;
  26.                     volleyCount++;
  27.                 }
  28.                 else if (gameName == "tennis")
  29.                 {
  30.                     pointsTennis += points * 1.05;
  31.                     tennisCount++;
  32.                 }
  33.                 else
  34.                 {
  35.                     pointsBadminton += points * 1.02;
  36.                     badmintonCount++;
  37.                 }
  38.             }
  39.  
  40.             double averageVolley = pointsVolley / volleyCount;
  41.             double averageTennis = pointsTennis / tennisCount;
  42.             double averageBadminton = pointsBadminton / badmintonCount;
  43.  
  44.             double full = pointsBadminton + pointsTennis + pointsVolley;
  45.  
  46.             if (averageBadminton >= 75 && averageTennis >= 75 && averageVolley >= 75)
  47.             {
  48.                 Console.WriteLine($"Congratulations, {name}! You won the cruise games with {Math.Floor(full)} points.");
  49.             }
  50.             else
  51.             {
  52.                 Console.WriteLine($"Sorry, {name}, you lost. Your points are only {Math.Floor(full)}.");
  53.             }
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement