StoimenK

C# 2.10 Rage Expenses

Jan 23rd, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.63 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _2._9._10_Rage_Expenses
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int lostGamesCount = int.Parse(Console.ReadLine());
  14.             double headsetPrice = double.Parse(Console.ReadLine());
  15.             double mousePrice = double.Parse(Console.ReadLine());
  16.             double keyboardPrice = double.Parse(Console.ReadLine());
  17.             double displayPrice = double.Parse(Console.ReadLine());
  18.  
  19.             int headsetTrashesh = 0;
  20.             int mouseTrashes = 0;
  21.             int displayTrashes = 0;
  22.             int keyboardTrashes = 0;
  23.  
  24.             for (int game = 1; game <= lostGamesCount; game++)
  25.             {
  26.                 bool keyboard = false;
  27.                 if (game % 2 == 0)
  28.                 {
  29.                     headsetTrashesh++;
  30.                 }
  31.                 if (game % 3 == 0)
  32.                 {
  33.                     mouseTrashes++;
  34.                 }
  35.                 if (game % 2 == 0 && game % 3 == 0)
  36.                 {
  37.                     keyboardTrashes++;
  38.                     keyboard = true;
  39.                 }
  40.                 if (keyboard && keyboardTrashes % 2 == 0 && keyboardTrashes != 0)
  41.                 {
  42.                     displayTrashes++;
  43.                 }
  44.             }
  45.  
  46.             double totalPrice = mouseTrashes * mousePrice + headsetTrashesh * headsetPrice + displayTrashes * displayPrice + keyboardTrashes * keyboardPrice;
  47.  
  48.             Console.WriteLine($"Rage expenses: {totalPrice:f2} lv.");
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment