Advertisement
Dianov

Basic Syntax, Conditional Statements and Loops - Exercise (10. Rage Expenses)

Mar 26th, 2021
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.50 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 RageExpenses
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int lostgames = int.Parse(Console.ReadLine());
  14.             decimal headsetPrice = decimal.Parse(Console.ReadLine());
  15.             decimal mousePrice = decimal.Parse(Console.ReadLine());
  16.             decimal keyboardPrice = decimal.Parse(Console.ReadLine());
  17.             decimal displayPrice = decimal.Parse(Console.ReadLine());
  18.  
  19.             int brokenHeadsetsCounter = 0;
  20.             int brokenMousesCounter = 0;
  21.             int brokenKeyboardsCounter = 0;
  22.             int brokenDisplaysCounter = 0;
  23.  
  24.             for (int i = 1; i <= lostgames; i++)
  25.             {
  26.                 if (i % 2 == 0)
  27.                 {
  28.                     brokenHeadsetsCounter += 1;
  29.                 }
  30.                 if (i % 3 == 0)
  31.                 {
  32.                     brokenMousesCounter += 1;
  33.                 }
  34.                 if (i % 2 == 0 && i % 3 == 0)
  35.                 {
  36.                     brokenKeyboardsCounter += 1;
  37.                 }                                
  38.             }
  39.             brokenDisplaysCounter = brokenKeyboardsCounter / 2;
  40.             Console.WriteLine($"Rage expenses: {(headsetPrice * brokenHeadsetsCounter + mousePrice * brokenMousesCounter + keyboardPrice * brokenKeyboardsCounter + displayPrice * brokenDisplaysCounter):F2} lv.");
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement