Advertisement
Valantina

Series

Jun 18th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05.Series
  4. {
  5.     class P05_Series
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.                 //Thrones – 50%
  10.                 //• Lucifer – 40 %
  11.                 //• Protector – 30 %
  12.                // • TotalDrama – 20 %
  13.                // • Area – 10 %
  14.  
  15.            double budget = double.Parse(Console.ReadLine());
  16.             int serials = int.Parse(Console.ReadLine());
  17.  
  18.             double totalPrice = 0;
  19.             for (int serial = 1; serial <= serials; serial++)
  20.             {
  21.                 string name = Console.ReadLine();
  22.                 double price = double.Parse(Console.ReadLine());
  23.  
  24.                 switch (name)
  25.                 {
  26.                     case "Thrones": price = 0.5 * price; break;
  27.                     case "Lucifer": price = 0.6 * price; break;
  28.                     case "Protector": price = 0.7 * price; break;
  29.                     case "TotalDrama": price = 0.8 * price; break;
  30.                     case "Area": price = 0.9 * price; break;
  31.  
  32.                 }
  33.                 totalPrice += price;
  34.             }
  35.  
  36.             if(budget >= totalPrice)
  37.             {
  38.                 double leftMoney = budget - totalPrice;
  39.                 Console.WriteLine($"You bought all the series and left with {leftMoney:F2} lv.");
  40.             }
  41.             else
  42.             {
  43.                 double needMoney = totalPrice - budget;
  44.                 Console.WriteLine($"You need {needMoney:F2} lv. more to buy the series!");
  45.             }
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement