Advertisement
abushik

Untitled

Dec 15th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp13
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int budjet = int.Parse(Console.ReadLine());
  10. string productName = Console.ReadLine();
  11. double counter = 0;
  12. double totalSum = 0;
  13. double resto = budjet;
  14.  
  15. while (productName != "Finish")
  16. {
  17. double order = 0;
  18.  
  19. switch (productName)
  20. {
  21. case "Star":
  22. order += 5.69;
  23. counter++;
  24. break;
  25. case "Angel":
  26. order += 8.49;
  27. counter++;
  28. break;
  29. case "Lights":
  30. order += 11.2;
  31. counter++;
  32. break;
  33. case "Wreath":
  34. order += 15.5;
  35. counter++;
  36. break;
  37. default:
  38. order += 3.59;
  39. counter++;
  40. break;
  41. }
  42. if (counter == 3)
  43. {
  44. order -= order * 0.30;
  45. }
  46. resto -= order;
  47. totalSum += order;
  48. if (resto < order)
  49. {
  50. Console.WriteLine($"Not enough money! You need {order - resto:F2}lv more.");
  51. Console.WriteLine($"{counter} items -> {totalSum:f2}lv spent.");
  52. return;
  53. }
  54. productName = Console.ReadLine();
  55. }
  56. if (productName == "Finish")
  57. {
  58. Console.WriteLine("Congratulations! You bought everything!");
  59. Console.WriteLine($"{counter} items -> {totalSum:f2}lv spent.");
  60. }
  61.  
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement