silvana1303

series

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