IvetValcheva

04. Toy Shop

Jan 17th, 2022
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Toy_Shop
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. //четем входните данни и ги запеметяваме в променливи
  10. double tripPrice = double.Parse(Console.ReadLine());
  11.  
  12. int puzzleQuantity = int.Parse(Console.ReadLine());
  13. int dollsQuantity = int.Parse(Console.ReadLine());
  14. int bearsQuantity = int.Parse(Console.ReadLine());
  15. int minionsQuantity = int.Parse(Console.ReadLine());
  16. int trucksQuantity = int.Parse(Console.ReadLine());
  17.  
  18. //намираме общия брой играчки
  19. int toysQuantity = puzzleQuantity + dollsQuantity + bearsQuantity
  20. + minionsQuantity + trucksQuantity;
  21.  
  22. //намираме общата сума на играчките
  23. double totalPrice =
  24. puzzleQuantity*2.6 +
  25. dollsQuantity*3 +
  26. bearsQuantity*4.1 +
  27. minionsQuantity*8.2 +
  28. trucksQuantity*2;
  29.  
  30. //проверяваме дали броя на закупените играчки е >=50
  31. //=> ако са >= 50 - трябва да извадим от общата сума 25%
  32. if (toysQuantity >= 50)
  33. {
  34. totalPrice = totalPrice - totalPrice*0.25; //totalPrice*(25/100.0)
  35. }
  36.  
  37. //трябва да извадим 10% от крайната сум за наем
  38. totalPrice = totalPrice - totalPrice * 0.10;
  39.  
  40.  
  41. //проверяваме дали пеалбата е достатъчна, за да отиде на екскурзия
  42. // =>ако печалбата >= цената на екс.
  43. // => отпечатаме "да" и колко пари й остават (общата сума-цената на екс.)
  44.  
  45. // =>ако печалбата < цената на екс.
  46. // => отп. "не" и колко пари не й достигат (цена на екс.-общата сума)
  47.  
  48. if (totalPrice >= tripPrice)
  49. {
  50. Console.WriteLine($"Yes! {(totalPrice-tripPrice):F2} lv left.");
  51. }
  52. else
  53. {
  54. Console.WriteLine($"Not enough money! {tripPrice- totalPrice:F2} lv needed.");
  55. }
  56.  
  57. }
  58. }
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment