Advertisement
mark79

Cruize Games

Jul 30th, 2019
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.98 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Cruize_Games
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.  
  10.             string namePlayer = Console.ReadLine();
  11.             int countGames = int.Parse(Console.ReadLine());
  12.  
  13.             double tempPointVolley = 0;
  14.             double tempPointTenis = 0;
  15.             double tempPointBadminton = 0;
  16.             double sumGameVoley = 0;
  17.             double sumGameTenis = 0;
  18.             double sumGameBadm = 0;
  19.  
  20.             for (int i = 0; i < countGames; i++)
  21.             {
  22.                 string nameGame = Console.ReadLine();
  23.                 double countPoints = double.Parse(Console.ReadLine());
  24.  
  25.                 if (nameGame == "volleyball")
  26.                 {
  27.                     tempPointVolley += countPoints * 1.07;
  28.                     sumGameVoley++;
  29.                 }
  30.                 else if (nameGame == "tennis")
  31.                 {
  32.                     tempPointTenis += countPoints * 1.05;
  33.                     sumGameTenis++;
  34.                 }
  35.                 else if (nameGame == "badminton")
  36.                 {
  37.                     tempPointBadminton += countPoints * 1.02;
  38.                     sumGameBadm++;
  39.                 }
  40.             }
  41.             double sumPoint = Math.Floor(tempPointVolley + tempPointBadminton + tempPointTenis);
  42.             tempPointVolley = Math.Floor(tempPointVolley / sumGameVoley);
  43.             tempPointTenis = Math.Floor(tempPointTenis / sumGameTenis);
  44.             tempPointBadminton = Math.Floor(tempPointBadminton / sumGameBadm);
  45.  
  46.             bool isWinner = tempPointBadminton >= 75 && tempPointTenis >= 75 && tempPointVolley >= 75;
  47.             if (isWinner)
  48.             {
  49.                 Console.WriteLine($"Congratulations, {namePlayer}! You won the cruise games with {sumPoint} points.");
  50.             }
  51.             else
  52.             {
  53.                 Console.WriteLine($"Sorry, {namePlayer}, you lost. Your points are only {sumPoint}.");
  54.             }
  55.  
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement