Advertisement
desislava_topuzakova

02. Summer Shopping

May 1st, 2020
763
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.57 KB | None | 0 0
  1. using System;
  2. using System.Diagnostics;
  3.  
  4. namespace demo
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.  
  11.             //плажна хавлия = вход
  12.             //чадър = хавлия * 2 / 3 - ok
  13.             //плажна чанта = 1 / 3 * (джапанки + хавлията)
  14.             //джапанки = 75% * чадър
  15.             //сума = хавлия + чадър + чанта + джапанки
  16.             //отстъпка -> 12% -> число ->  
  17.             //проверим дали и стига бюджетът
  18.  
  19.             int budget = int.Parse(Console.ReadLine());
  20.             double towelPrice = double.Parse(Console.ReadLine());
  21.             int discountPercent = int.Parse(Console.ReadLine());
  22.  
  23.             double umbrellaPrice = towelPrice * 2 / 3;
  24.             double flipflopsPrice = 0.75 * umbrellaPrice;
  25.             double bagPrice = (flipflopsPrice + towelPrice) / 3;
  26.             double totalSum = towelPrice + umbrellaPrice + bagPrice + flipflopsPrice;
  27.  
  28.             totalSum = totalSum - (discountPercent / 100.0) * totalSum;
  29.  
  30.             if(budget >= totalSum)
  31.             {
  32.                 double leftMoney = budget - totalSum;
  33.                 Console.WriteLine($"Annie's sum is {totalSum:F2} lv. She has {leftMoney:F2} lv. left.");
  34.             }
  35.             else
  36.             {
  37.                 double needMoney = totalSum - budget;
  38.                 Console.WriteLine($"Annie's sum is {totalSum:F2} lv. She needs {needMoney:F2} lv. more.");
  39.             }
  40.  
  41.  
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement