Advertisement
IvanITD

04.ToyShop

Jan 15th, 2024
642
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.57 KB | Source Code | 0 0
  1.  
  2. double priceForExcursion = double.Parse(Console.ReadLine());
  3. int puzzleAmount = int.Parse(Console.ReadLine());
  4. int talkingDollsAmount = int.Parse(Console.ReadLine());
  5. int tedyBearAmount = int.Parse(Console.ReadLine());
  6. int minionsAmount = int.Parse(Console.ReadLine());
  7. int trucksAmount = int.Parse(Console.ReadLine());
  8.  
  9. double totalToys = puzzleAmount + talkingDollsAmount + tedyBearAmount + minionsAmount + trucksAmount;
  10.  
  11. double puzzlePrice = puzzleAmount * 2.60;
  12. double talkingDollPrice = talkingDollsAmount * 3;
  13. double tedyBearPrice = tedyBearAmount * 4.10;
  14. double minionsPrice = minionsAmount * 8.20;
  15. double truckPrice = trucksAmount * 2;
  16.  
  17. double totalPrice = puzzlePrice + talkingDollPrice + tedyBearPrice + minionsPrice + truckPrice;
  18.  
  19. if (totalToys >= 50)
  20. {
  21.     double discount = totalPrice * 0.25;
  22.     double discountFromTotalPrice = totalPrice - discount;
  23.  
  24.     double rentPrice = discountFromTotalPrice * 0.10;
  25.     double profit = discountFromTotalPrice - rentPrice;
  26.  
  27.     if (profit >= priceForExcursion)
  28.     {
  29.         Console.WriteLine($"Yes! {profit - priceForExcursion:F2} lv left.");
  30.     }
  31.     else
  32.     {
  33.         Console.WriteLine($"Not enough money! {priceForExcursion - profit:F2} lv needed.");
  34.     }
  35. }
  36. else
  37. {
  38.     double rentPrice = totalPrice * 0.10;
  39.     double profit = totalPrice - rentPrice;
  40.  
  41.     if (profit >= priceForExcursion)
  42.     {
  43.         Console.WriteLine($"Yes! {profit - priceForExcursion:F2} lv left.");
  44.     }
  45.     else
  46.     {
  47.         Console.WriteLine($"Not enough money! {priceForExcursion - profit:F2} lv needed.");
  48.     }
  49. }
  50.  
Tags: C#
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement