Advertisement
sanyakasarova

02. Summer Shopping

Jun 6th, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         int budget = int.Parse(Console.ReadLine());
  8.         double beachTowelPrice = double.Parse(Console.ReadLine());
  9.         int discount = int.Parse(Console.ReadLine());
  10.  
  11.  
  12.         // 2. Calculate the prices of all items
  13.         double umbrellaPrice = 2.0 / 3 * beachTowelPrice;
  14.         double flipFlopsPrice = 0.75 * umbrellaPrice;
  15.         double bagPrice = 1.0 / 3 * (beachTowelPrice + flipFlopsPrice);
  16.  
  17.         // 3. Calculate the total bill
  18.         double total = beachTowelPrice + umbrellaPrice + flipFlopsPrice + bagPrice;
  19.  
  20.         // 4. Discount
  21.         total -= discount / 100.00 * total;
  22.  
  23.         // 5. Check if the money she has is enough
  24.  
  25.         if (budget >= total)
  26.         {
  27.             Console.WriteLine($"Annie's sum is {total:f2} lv. She has {budget-total:f2} lv. left.");
  28.         }
  29.         else
  30.         {
  31.             Console.WriteLine($"Annie's sum is {total:f2} lv. She needs {total - budget:f2} lv. more.");
  32.         }
  33.  
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement