Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.73 KB | None | 0 0
  1. using System;
  2.  
  3. namespace For
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double budget = double.Parse(Console.ReadLine());
  10.             int countSeries = int.Parse(Console.ReadLine());
  11.             double sum = 0.0;
  12.  
  13.             for (int info = 1; info <= countSeries; info++)
  14.             {
  15.                 string serial = Console.ReadLine();
  16.                 double priceForSerial = double.Parse(Console.ReadLine());
  17.  
  18.                
  19.  
  20.                 if (serial == "Thrones")
  21.                 {
  22.                     priceForSerial = priceForSerial * 0.5;
  23.                 }
  24.                 else if(serial == "Lucifer")
  25.                 {
  26.                     priceForSerial = priceForSerial * 0.6;
  27.                 }
  28.                 else if (serial == "Protector")
  29.                 {
  30.                     priceForSerial = priceForSerial * 0.7;
  31.                 }
  32.                 else if (serial == "TotalDrama")
  33.                 {
  34.                     priceForSerial = priceForSerial * 0.8;
  35.                 }
  36.                 else if (serial == "Area")
  37.                 {
  38.                     priceForSerial = priceForSerial * 0.9;
  39.                 }
  40.                 else
  41.                 {
  42.                     priceForSerial = priceForSerial * 1;
  43.                 }
  44.  
  45.                 sum += priceForSerial;
  46.             }
  47.             if (budget >= sum)
  48.             {
  49.                 Console.WriteLine($"You bought all the series and left with {Math.Abs(budget-sum):f2} lv.");
  50.  
  51.             }
  52.             else
  53.             {
  54.                 Console.WriteLine($"You need {Math.Abs(sum-budget):f2} lv. more to buy the series!");
  55.             }
  56.            
  57.            
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement