Advertisement
spasnikolov131

Untitled

Jun 12th, 2022
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Concatenate_data
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int targetPrice = int.Parse(Console.ReadLine());
  10. double sum = 0;
  11. double totalSum = 0;
  12.  
  13.  
  14.  
  15. while (true)
  16. {
  17. string nameOfTheCocktail = Console.ReadLine();
  18. if (nameOfTheCocktail == "Party!")
  19. {
  20. Console.WriteLine($"We need {targetPrice - totalSum:f2} leva more.");
  21. break;
  22. }
  23. int price = int.Parse(Console.ReadLine());
  24. double nameLength = nameOfTheCocktail.Length;
  25.  
  26. sum = nameLength * price;
  27. totalSum += sum;
  28.  
  29. if (sum % 2 != 0)
  30. {
  31. totalSum = totalSum - (totalSum * 0.25);
  32. }
  33.  
  34. if (totalSum > targetPrice)
  35. {
  36. Console.WriteLine("Target acquired.");
  37. break;
  38. }
  39.  
  40.  
  41. }
  42.  
  43. Console.WriteLine($"Club income - {totalSum:f2} leva.");
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement