Advertisement
madeofglass

Untitled

Feb 24th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05.Series
  4. {
  5.     class Series
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double budget = double.Parse(Console.ReadLine());
  10.             double TVshowsNum = double.Parse(Console.ReadLine());
  11.  
  12.             double priceAll = 0.0;
  13.  
  14.             for (int i = 1; i <= TVshowsNum; i++)
  15.             {
  16.                 string nameTVshow = Console.ReadLine();
  17.                 double pricePerTVshow = double.Parse(Console.ReadLine());
  18.  
  19.                 if (nameTVshow == "Thrones")
  20.                 {
  21.                     pricePerTVshow = pricePerTVshow * 0.50;
  22.                 }
  23.                 else if (nameTVshow == "Lucifer")
  24.                 {
  25.                     pricePerTVshow = pricePerTVshow * 0.60;
  26.                 }
  27.                 else if (nameTVshow == "Protector")
  28.                 {
  29.                     pricePerTVshow = pricePerTVshow * 0.70;
  30.                 }
  31.                 else if (nameTVshow == "TotalDrama")
  32.                 {
  33.                     pricePerTVshow = pricePerTVshow * 0.80;
  34.                 }
  35.                 else if (nameTVshow == "Area")
  36.                 {
  37.                     pricePerTVshow = pricePerTVshow * 0.90;
  38.                 }
  39.  
  40.                 priceAll += pricePerTVshow;
  41.             }
  42.  
  43.             double difference = Math.Abs(budget - priceAll);
  44.  
  45.             if (budget >= priceAll)
  46.             {
  47.                 Console.WriteLine($"You bought all the series and " +
  48.                     $"left with {difference:f2} lv.");
  49.             }
  50.             else
  51.             {
  52.                 Console.WriteLine($"You need {difference:f2} lv. more to buy the series!");
  53.             }
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement