Advertisement
Guest User

Untitled

a guest
Apr 14th, 2020
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _04.TouristShopM2
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. double oneProductPrice = 0.0;
  10. double sumProductPrice = 0.0;
  11. int countProducts = 0;
  12.  
  13. double budget = double.Parse(Console.ReadLine());
  14. string productName = Console.ReadLine();
  15.  
  16. while (productName != "Stop")
  17. {
  18. oneProductPrice = double.Parse(Console.ReadLine());
  19. countProducts++;
  20. if (countProducts % 3 == 0) oneProductPrice = oneProductPrice / 2.0;
  21. if (oneProductPrice > budget)
  22. {
  23. Console.WriteLine("You don't have enough money!");
  24. Console.WriteLine($"You need {oneProductPrice - budget:F2} leva!");
  25. return;
  26. }
  27. sumProductPrice += oneProductPrice;
  28. budget -= oneProductPrice;
  29. productName = Console.ReadLine();
  30. }
  31. Console.WriteLine($"You bought {countProducts} products for {sumProductPrice:F2} leva.");
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement